Skip to content
Go back

Golang 一些特殊的导包方法

Edit page

Golang 一些特殊的导包方法

package main

import (
	. "fmt"
	f "fmt"

	// call the 'init' function in fmt, unnecessary to use the lib
	_ "fmt"
)

func main() {
	Println("call fmt without prefix")
	f.Println("call fmt with alias")

}

另外还能用相对路径和绝对路径来导包。

import   "./model"  //当前文件同一目录的model目录,但是不建议这种方式import
import   "shorturl/model"  //加载GOPATH/src/shorturl/model模块

Edit page
Share this post on:

Previous Post
backtrader 基础
Next Post
毕设