这个问题在这里已经有了答案:Whyisn'tshortvariabledeclarationallowedatpackagelevelinGo?(3个答案)WhytherearetwowaysofdeclaringvariablesinGo,what'sthedifferenceandwhichtouse?(1个回答)关闭4年前。我是Go新手,正在学习这门语言的基础知识。这就是我被困的地方。我从基础类(class)中了解到,varxint=10和x:=10应该是等价的,后者是简写符号。这一切都有意义,直到这两个在main()函数中。这意味着:packagemainimport"fmt"