-
macOS에서 golang 크로스 컴파일하기맥초보 2023. 1. 25. 22:53반응형
이전에 맥에서 윈도용 혹은 리눅스용 바이너리를 만들 수 있다
환경 설정을 하고 컴파일을 하면 간단하다
먼저 환경 변수를 설정해야 하는데
GOOS, GOARCH 환경변수를 설정한다
값은
https://go.dev/doc/install/source
Installing Go from source - The Go Programming Language
Installing Go from source This topic describes how to build and run Go from source code. To install with an installer, see Download and install. Introduction Go is an open source project, distributed under a BSD-style license. This document explains how to
go.dev
에서 확인이 가능하다
맥에서 윈도용으로 컴파일을 해보자
export GOOS=windows ;export GOARCH=amd64;go build -o geoip3.exe geoip3.go
이렇게 컴파일을 하면 위와 같이 윈도용 바이너리인 exe 포맷의 바이너리 컴파일이 가능하다
위 사이트의 환경변수를 잘 보고 설정을 하면 어떤 OS 의 바이너리도 가능
훌륭하다 golang
반응형'맥초보' 카테고리의 다른 글
MacOS 단축키 (0) 2023.01.29 Apple Silicon MacOS, Vmware Fusion에 Win11 ARM64 설치 (0) 2023.01.28 macOS에서 golang 개발환경 설정 (0) 2023.01.25 M1 맥북에서 ARM Windows 구동 영상 (0) 2020.12.03 M1 칩 macOS에서 ARM Windows 10 구동 (0) 2020.11.30