#Go 1.21新增的 log/slog 完美解决了以上问题,并且带来了很多其他很实用的特性。
本次编译不使用log/slog 包
- su -
- echo $GOPATH ;echo $GOROOT;
- cd /tmp;
- busybox wget --no-check-certificate https://go.dev/dl/go1.18.linux-amd64.tar.gz;\
- which tar&&tar -xvf go1.18.linux-amd64.tar.gz >/dev/null &
- cd /tmp;
- git clone https://github.com/Hel10-Web/Databasetools;
- cd /tmp/Databasetools;
-
-
-
-
- /tmp/go/bin/go env -w GO111MODULE=on ;
- /tmp/go/bin/go get github.com/godror/godror@v0.36.0
- /tmp/go/bin/go get ;
- /tmp/go/bin/go install;
-
- /tmp/go/bin/go build -ldflags="-s -w" -o Databasetools_x64.elf main.go;
- ./Databasetools_x64.elf --help
-
package log/slog is not in GOROOT (/opt/hostedtoolcache/go/1.20.8/x64/src/log/slog)
#/root/go/pkg/mod/github.com/godror/godror@v0.40.2/drv.go:85:2: package log/slog is not in GOROOT (/opt/hostedtoolcache/go/1.20.8/x64/src/log/slog)
- root@fv-az180-891:/tmp/Databasetools# go install github.com/godror/godror@v0.36.0
- package github.com/godror/godror is not a main package
- root@fv-az180-891:/tmp/Databasetools#
- root@fv-az180-891:/tmp/Databasetools# go list -m github.com/godror/godror
- github.com/godror/godror v0.36.0
- root@fv-az180-891:/tmp/Databasetools#
继续编译Windows下的exe文件:
- #apt-get update;
- apt-get install -y gcc-multilib gcc-mingw-w64
-
- /tmp/go/bin/go env -w CGO_ENABLED=1
- /tmp/go/bin/go env -w GOOS=windows
- /tmp/go/bin/go env -w GO111MODULE=on
- /tmp/go/bin/go env -w CC=x86_64-w64-mingw32-gcc
-
- #/tmp/go/bin/go env -w CXX_FOR_TARGET=i686-w64-mingw32-g++
- #/tmp/go/bin/go env -w CC_FOR_TARGET=i686-w64-mingw32-gcc
-
- #/tmp/go/bin/go build -ldflags="-s -w" -buildmode=c-shared -o Databasetools_x64.exe main.go
-
- /tmp/go/bin/go build -ldflags="-s -w" -o Databasetools_x64a.exe main.go
-
-
- root@fv-az180-891:/tmp/Databasetools# file Databasetools_x64.exe
- Databasetools_x64.exe: PE32+ executable (DLL) (console) x86-64 (stripped to external PDB), for MS Windows
- root@fv-az180-891:/tmp/Databasetools# file Databasetools_x64.elf
- Databasetools_x64.elf: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=6f277746fbc5dc1b221106549984bd56072a5059, for GNU/Linux 3.2.0, stripped
- root@fv-az180-891:/tmp/Databasetools# /tmp/go/bin/go build -ldflags="-s -w" -o Databasetools_x64a.exe main.go
- root@fv-az180-891:/tmp/Databasetools# file Databasetools_x64a.exe
- Databasetools_x64a.exe: PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows
- root@fv-az180-891:/tmp/Databasetools#
- root@fv-az180-891:/tmp/Databasetools# ls -al
- total 35980
- drwxr-xr-x 6 root root 4096 Sep 30 05:21 .
- drwxrwxrwt 21 root root 4096 Sep 30 05:21 ..
- drwxr-xr-x 8 root root 4096 Sep 30 05:02 .git
- -rw-r--r-- 1 root root 66 Sep 30 05:01 .gitattributes
- -rwxr-xr-x 1 root root 12170392 Sep 30 05:02 Databasetools_x64.elf
- -rw-r--r-- 1 root root 12254208 Sep 30 05:17 Databasetools_x64.exe
- -rwxr-xr-x 1 root root 12255744 Sep 30 05:21 Databasetools_x64a.exe
- -rw-r--r-- 1 root root 57 Sep 30 05:01 crontab.txt
- drwxr-xr-x 2 root root 4096 Sep 30 05:01 driver
- -rw-r--r-- 1 root root 16896 Sep 30 05:01 exp.dll
- -rw-r--r-- 1 root root 44320 Sep 30 05:01 exp.so
- -rw-r--r-- 1 root root 1041 Sep 30 05:01 go.mod
- -rw-r--r-- 1 root root 7667 Sep 30 05:01 go.sum
- -rw-r--r-- 1 root root 75 Sep 30 05:01 main.go
- -rw-r--r-- 1 root root 62 Sep 30 05:01 out.json
- drwxr-xr-x 2 root root 4096 Sep 30 05:01 pac
- -rw-r--r-- 1 root root 25960 Sep 30 05:01 readme.md
- drwxr-xr-x 2 root root 4096 Sep 30 05:01 shell
- -rw-r--r-- 1 root root 18 Sep 30 05:01 shell.txt
- -rw-r--r-- 1 root root 1 Sep 30 05:01 ssh.txt
- root@fv-az180-891:/tmp/Databasetools#
- root@fv-az589-754:/tmp/Databasetools# GO111MODULE=on CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-w -s" -o gossh99.exe main.go;
- # github.com/godror/godror
- /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:531:19: undefined: VersionInfo
- /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:532:19: undefined: VersionInfo
- /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:533:10: undefined: StartupMode
- /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:534:11: undefined: ShutdownMode
- /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:536:31: undefined: Event
- /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:536:42: undefined: SubscriptionOption
- /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:536:64: undefined: Subscription
- /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:537:31: undefined: ObjectType
- /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:538:59: undefined: Data
- /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:539:28: undefined: DirectLob
- /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:539:28: too many errors