go-crosscompile/README.md

44 lines
1.5 KiB
Markdown
Raw Permalink Normal View History

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:
```sh
go build .
./app
# Output:
#1+2=linux
#a/b/c
```
---
```sh
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
```
---
```sh
file app*
# see information about executables
```
# HELP NEEDED
2023-09-01 10:01:12 +03:00
- VSCode gives redecleration error when using same name as function names. How to solve this?
2023-08-30 21:14:10 +03:00
maybe see https://github.com/golang/go/issues/29202 ?
2023-09-01 10:01:12 +03:00
- see more in this [doc](https://git.aliberksandikci.com.tr/Liderahenk/ahenk-docs/src/branch/main/dev/environment.md#fixme-build-flag-issues)
2023-08-30 21:14:10 +03:00
# Before trying
- make sure you have installed **wine** in your linux system
- or use a windows system too
# Resources
- https://www.digitalocean.com/community/tutorials/customizing-go-binaries-with-build-tags
- https://www.digitalocean.com/community/tutorials/building-go-applications-for-different-operating-systems-and-architectures
- https://www.digitalocean.com/community/tutorials/how-to-build-go-executables-for-multiple-platforms-on-ubuntu-20-04
- https://opensource.com/article/21/1/go-cross-compiling
2023-09-01 10:01:12 +03:00
# Extra
- see https://git.aliberksandikci.com.tr/asandikci/go-loader-test/src/branch/eh-steve/goloader+crosscompile for usage with new goloader plugin logic