英文:
Unable to reference my own packages
问题
我已经创建了一个接口和一个结构体,但每次保存我的Go文件时,编译器都会格式化我的import
语句,并指示我的结构体未定义。
我对Go完全不熟悉,所以对于某些人来说,这可能很明显。我已经阅读了文档。
我如何正确引用我创建的类型?
英文:
I have created an interface as well as a struct, but every time I save my Go file, the compiler is formatting away my import
statement and indicating that my struct is undefined.
I'm totally new to Go, so this probably seems obvious to someone. I've read the documentation.
How do I properly reference a type I've created?
答案1
得分: 2
当名称来自另一个包时,您需要进行限定。请在左侧的文件中尝试使用models.HttpResult
。
英文:
You have to qualify a name when it's coming from another package. Try models.HttpResult
in the file on the left.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论