英文:
Name clashes in Go imports
问题
考虑下面的Go代码..
package main
import "go/token"
import "python/token"
func main() {
x := token.INDENT
}
如何解决上述代码中token的歧义问题?是否有类似于Python表达式import python.token as pytoken
的方式?
英文:
Consider the Go code below..
package main
import "go/token"
import "python/token"
func main() {
x := token.INDENT
}
What is the best way to solve the ambiguity of token in the above code? Is there something similar to the python expression of import python.token as pytoken
?
答案1
得分: 5
例如,
package main
import "go/token"
import pytoken "python/token"
func main() {
g := token.INDENT // "go/token"
p := pytoken.INDENT // "python/token"
}
英文:
For example,
package main
import "go/token"
import pytoken "python/token"
func main() {
g := token.INDENT // "go/token"
p := pytoken.INDENT // "python/token"
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论