That error seems to be from writing that expression outside of a function.
There's no problem with structs supporting string fields:
https://play.golang.org/p/YeP2qhRdxp.

On Tue, Dec 13, 2016 at 10:45 AM, Betsy Lichtenberg <bet...@nestlabs.com>
wrote:

> Do structs support strings? I tried this:
>
>     type Params struct {
>       auth string
>     }
>
>     func doIt(p Params) string {
>       return p.auth
>     }
>
>     doIt(Params{auth: xxxx})
>
>
> I'm getting these errors:
>
> betsyl-macbookpro:~ betsyl$ go run get1.go
>
> # command-line-arguments
>
> ./get1.go:25: syntax error: unexpected doIt, expecting (
>
> ./get1.go:29: syntax error: unexpected literal .2, expecting comma or }
>
> On Tue, Dec 13, 2016 at 7:11 AM, Val <delepl...@gmail.com> wrote:
>
>> Hello Betsy
>> There is no "passing optional arguments by name" in go.
>>
>> This link [1] has an overview what what can or can't be done for optional
>> params :
>> - the *Functional options* technique.
>> - or you may define a struct as parameter, then call it with only the
>> fields you're interested in : [2]
>> This implies that "the zero values must be meaningful (i.e. acceptable in
>> your context : nil, 0, etc.)"
>>
>>   things := Things{amount: 13}
>>   show(things)
>>
>> [1] http://stackoverflow.com/questions/2032149/optional-parameters
>> [2] https://play.golang.org/p/yiKzomwTKM
>>
>> On Tuesday, December 13, 2016 at 6:46:23 AM UTC+1, bet...@google.com
>> wrote:
>>>
>>> Hi,
>>>
>>> In Python, I can include params like this:
>>>
>>> =====================
>>>
>>> *params = {'auth': 'XXXXXXXX'}*
>>>
>>> response = requests.request("GET", url, data=payload, headers=headers,
>>> *params=params*)
>>>
>>> =====================
>>>
>>> Any pointers on how Golang does this?
>>>
>>> Thanks,
>>> Betsy
>>>
>>
> --
> 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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to