源码目录:
root@VM-0-12-ubuntu:~/go-path/src/test# pwd /root/go-path/src/test root@VM-0-12-ubuntu:~/go-path/src/test# tree . ├── go.mod ├── hello │ └── hello.go └── main.go 1 directory, 3 files root@VM-0-12-ubuntu:~/go-path/src/test#
main.go
package main
import (
"fmt"
"test/hello"
)
func main() {
hello.Hello()
fmt.Println("aa")
}
hello/hello.go
package hello
import (
"fmt"
)
func Hello() {
fmt.Println("hello api")
}
环境:
root@VM-0-12-ubuntu:~/go-path/src/test# go env GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/root/.cache/go-build" GOENV="/root/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/root/go-path/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/root/go-path" GOPRIVATE="" GOPROXY="https://goproxy.io" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/root/go-path/src/test/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build614597735=/tmp/go-build -gno-record-gcc-switches" root@VM-0-12-ubuntu:~/go-path/src/test#
编译运行:
root@VM-0-12-ubuntu:~/go-path/src/test# go build root@VM-0-12-ubuntu:~/go-path/src/test# ./test hello api aa root@VM-0-12-ubuntu:~/go-path/src/test#



