zhk_tiger
zhk_tiger

Reputation: 61

Go "cannot find package"

I have a public repository https://github.com/zhksoftGo/Packet. I have put some common go files in it. Currently, there are two.

 Packet.go under github.com/zhksoftGo/Packet
 TypeDefineCactus.go under github.com/zhksoftGo/Packet/protocol/Cactus/

I meet trouble at importing one of them.

import "github.com/zhksoftGo/Packet"   // works fine
import "github.com/zhksoftGo/Packet/protocol/Cactus" // "cannot find package"

//referer project .mod file:

module github.com/zhksoftGo/SnowWolf

go 1.15

require (
    github.com/gookit/slog v0.1.3
    github.com/panjf2000/gnet v1.4.2
    github.com/smartystreets/goconvey v1.6.4 // indirect
    github.com/zhksoftGo/Packet v0.0.0-20210320131229-5311a044e61f
    gopkg.in/ini.v1 v1.62.0
)

I have already set GO111MODULE=on. Could somebody help on this?

Upvotes: 0

Views: 731

Answers (1)

zhk_tiger
zhk_tiger

Reputation: 61

The root reason is my generator inserts utf-8 BOM chars in the generated Go file header. It works if a normal Go file import a generated Go file. But does not work if the generated Go file has another generated Go file imported. So for Go source file, we'd better use UTF-8.

Upvotes: 1

Related Questions