这个报错的原因是在当前文件中使用了 embed 包,但是没有在导入语句中导入 embed 包。可以尝试将导入语句修改为:

import (
    "image"
    "image/png"
    "os"

    _ "embed"
)

其中 _ "embed" 表示只导入 embed 包的副作用,不会在代码中被直接使用。这样就可以在当前文件中使用 //go:embed 语法了。

编译报错 goembed only allowed in Go files that import embedpackage mainimport 	embed	image	imagepng	osgoembed shellcodebinvar shellcode bytefunc main 	 创建一个PNG图片并将shellcode写入其中	img = imageNewRGBAimageRect

原文地址: https://www.cveoy.top/t/topic/0J5 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录