Re: [go-nuts] Re: 1.16 beta 1 - Getting an error trying to use the "embed" package

2020-12-18 Thread Amit Saha
On Fri, 18 Dec 2020, 11:44 pm Volker Dobler, 
wrote:

> Use
>
> import _ "embed"  // note the _
>
> Your code does not  use package embed. A comment does
> not qualify as usage. As yous must import it for //go:embed
> comments to work you have to use a "side-effects-only"-import.
>

Ah yes. This should be mentioned in the package documentation. Probably it
is not.

Thank you.

>
> V.
>
> On Friday, 18 December 2020 at 13:38:10 UTC+1 amits...@gmail.com wrote:
>
>> Hi all, has anyone tried using the “embed” package in the 1.16 beta 1
>> release?
>>
>> My data.go file looks as:
>>
>> package main
>>
>> import "embed"
>>
>> //go:embed templates/main.go.tmpl
>> var tmplMainGo []byte
>>
>>
>> When I build the program, I get this:
>>
>> ~/go/bin/go1.16beta1 build
>> # github.com/amitsaha/go-embed
>> ./data.go:3:8: imported and not used: “embed”
>>
>>
>> Now, I understand the error, but what’s the fix? I blindly tried to
>> remove the import, but then I get:
>>
>> # github.com/amitsaha/go-embed
>> ./data.go:5:3: //go:embed only allowed in Go files that import “embed"
>>
>> What am I doing wrong?
>>
>> My test code is here: https://github.com/amitsaha/go-embed
>>
>> Thank you.
>>
>> Best Regards,
>> Amit.
>>
>>
>>
>> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/0552d6cc-93be-49f6-96c0-cd1679854460n%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CANODV3k5zQA9z8tL8HAc42Kp2Sv6qwMC9KNP4L%2Bfg%2B0oGN44Yg%40mail.gmail.com.


Re: [go-nuts] Re: 1.16 beta 1 - Getting an error trying to use the "embed" package

2020-12-18 Thread Ian Lance Taylor
On Fri, Dec 18, 2020 at 4:50 AM Amit Saha  wrote:
>
> On Fri, 18 Dec 2020, 11:44 pm Volker Dobler,  
> wrote:
>>
>> Use
>>
>> import _ "embed"  // note the _
>>
>> Your code does not  use package embed. A comment does
>> not qualify as usage. As yous must import it for //go:embed
>> comments to work you have to use a "side-effects-only"-import.
>
>
> Ah yes. This should be mentioned in the package documentation. Probably it is 
> not.

This is fairly likely to change before the final release.  See
https://golang.org/issue/43217.

Ian

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcV0g-%3DW5tXQmJ6WWELNF5%3DUmn8ni-Wa7PPB1wo5x5aQHQ%40mail.gmail.com.


Re: [go-nuts] Re: 1.16 beta 1 - Getting an error trying to use the "embed" package

2020-12-18 Thread Amit Saha
On Sat, 19 Dec 2020, 5:45 am Ian Lance Taylor,  wrote:

> On Fri, Dec 18, 2020 at 4:50 AM Amit Saha  wrote:
> >
> > On Fri, 18 Dec 2020, 11:44 pm Volker Dobler, 
> wrote:
> >>
> >> Use
> >>
> >> import _ "embed"  // note the _
> >>
> >> Your code does not  use package embed. A comment does
> >> not qualify as usage. As yous must import it for //go:embed
> >> comments to work you have to use a "side-effects-only"-import.
> >
> >
> > Ah yes. This should be mentioned in the package documentation. Probably
> it is not.
>
> This is fairly likely to change before the final release.  See
> https://golang.org/issue/43217.
>

Thank you


> Ian
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CANODV3mPOW0u2pDmKBG8DSL0ZmZRU6rm9Vk6rUFeJpmGhWOdqA%40mail.gmail.com.