GO Package的理解


import "fmt"

双引号其实指向的是目录,$GoPath + "fmt" ,引入的Package 实际上是 改目录下的唯一包名。如:package fmt

只是Go 习惯把目录名和package name保持一致。

其中有三种引用方式

Import 声明 路径               代码中使用

import     "lib/math"         math.Sin
import m   "lib/math"         m.Sin
import .   "lib/math"         Sin

参考资料:https://tonybai.com/2015/03/09/understanding-import-packages/

原文地址:https://www.cnblogs.com/tomahawk/p/10805362.html