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.
V.
On Friday, 18 December 2020 at 13:38:10 UTC+1 [email protected] 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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/0552d6cc-93be-49f6-96c0-cd1679854460n%40googlegroups.com.