此问题已在此处有答案:
imported and not used error(1个答案)
rand package error in Go(2个答案)
15天前关闭。
我尝试导入一个go包,但得到以下错误:
.\data.go:10:2: "github.com/username/test/my-project/model" imported and not used
.\data.go:38:13: undefined: DataModel
这些是我的go文件:
main.go
package main
func main() {consumeApi()}
data.go
package main
import(
"github.com/username/test/my-project/model"
)
func consumeApi() {
...
var result DataModel
if err := json.Unmarshal(body, &result); err != nil {
fmt.Println("Can not unmarshal JSON")
}
...
}
model.go
package model
type DataModel struct {
...
}
go.mod
module github.com/username/test/my-project
go 1.21.0
有人能帮我解决吗?
1条答案
按热度按时间rn0zuynd1#
取代
到