temporary test for understanding making a cross-compile go program.
Find a file
2023-08-30 21:14:10 +03:00
cmd/app Initial Commit 2023-08-30 21:14:10 +03:00
pkg/mypkg Initial Commit 2023-08-30 21:14:10 +03:00
go.mod Initial Commit 2023-08-30 21:14:10 +03:00
README.md Initial Commit 2023-08-30 21:14:10 +03:00

Go Crosscompile

Explanation

symbol() function in pkg/mypkg/symbol_linux.go and symbol_windows.go is different. When running and building program, GOOS choses right one. for more information run these in cmd/app/ directory:

  go build .
  ./app
  # Output:
  #1+2=linux
  #a/b/c

  env GOOS=windows GOARCH=amd64 go build .
  ./app.exe
  # Output:
  # -Some random wine logs if running on linux with wine-
  #1-2=windows
  #a\b\c 

  file app*
  # see information about executables

HELP NEEDED

VSCode gives redecleration error when using same name as function names. How to solve this? maybe see https://github.com/golang/go/issues/29202 ?

Before trying

  • make sure you have installed wine in your linux system
    • or use a windows system too

Resources