This is a creation in Article, where the information may have evolved or changed.
A note on the path mentioned in Go Web programming:
1 Relative paths
Import ". Model"//<--is the model directory of the same directory as the current file, but it is not recommended to use this method to guide the package
2 Absolute path
Import "Shortcut/model"//<--load Gopath/src/shortulr/model module
Point operation
We sometimes see the following ways to import packages
Import (. "FMT")
This point operation means that after the package is imported, you can omit the prefix's package name when you call the package's function, which is the FMT you used earlier. Println ("Hello World") can be omitted written in Println ("Hello World"), no-smell video on the recommendation not to use such a way, poor readability
alias operation
Alias operation as the name implies, we can name the package another one that we remember easily.
import (F "FMT") when calling the package function, the prefix becomes our prefix, that is, F. Println ("Hello World"), personally do not like this way, good System package call name you changed, other people read the code much uncomfortable _ Operation
Import (
"Database/sql"
_ "GitHub. com/z iutek/mymysql/godrv "//<----very Important thank you, thank God, I know what this crap means.
) _ operation is actually to introduce the package, instead of directly using the function inside the package, instead of calling the INIT function inside the package