FAQ
Hi, everybody.

I have a function which return INIConfig and error. It's easy to use

config, err := NewINIConfig()

to accept the return values.

But when I special return types for these variables, the compiler return
error.

config Configer, err error := NewINIConfig()

Because Configer is an interface, I want to special the variable type to
it. But it seems the golang don't support this way now? Or any other better
ways to solve this problem? Thank you in advance.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Matt Harden at Dec 28, 2014 at 6:22 pm
    That's not valid syntax. You can use

    var config Configer
    var err error
    config, err = NewINIConfig()

    On Sun Dec 28 2014 at 12:12:07 PM wrote:

    Hi, everybody.

    I have a function which return INIConfig and error. It's easy to use

    config, err := NewINIConfig()

    to accept the return values.

    But when I special return types for these variables, the compiler return
    error.

    config Configer, err error := NewINIConfig()

    Because Configer is an interface, I want to special the variable type to
    it. But it seems the golang don't support this way now? Or any other better
    ways to solve this problem? Thank you in advance.

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 28, '14 at 6:11p
activeDec 28, '14 at 6:22p
posts2
users2
websitegolang.org

2 users in discussion

Haosdent: 1 post Matt Harden: 1 post

People

Translate

site design / logo © 2022 Grokbase