저어가 보려고 쓰는 메모 ㅇㅂㅇㅎ



모듈을 내 계정으로 포크 떠서 가져오기

go mod replace는 로컬만 되는게 아니라 리모트 저장소도 가능

PR 날려도 원작자로부터 반응이 없어서 직접 포크 뜨고 수정해서 쓸 때 소스 안에 패키지 이름을 하나하나 바꿀 필요 없음.


* go.mod 편집

module my-program

go 1.22.2

require (
github.com/mattn/go-tty v0.0.5
)

require (
github.com/mattn/go-isatty v0.0.20 // indirect
golang.org/x/sys v0.19.0 // indirect
)

replace github.com/mattn/go-tty => github.com/practice-golang/go-tty latest


* 명령

go mod edit -replace github.com/mattn/go-tty=github.com/practice-golang/go-tty@latest



크로스컴파일

gox 사용

# Makefile

dest = bin
version = 0.0.1

dist:
go get -d github.com/mitchellh/gox
go build -mod=readonly -o $(dest)/ github.com/mitchellh/gox
go mod tidy
go env -w GOFLAGS=-trimpath

$(dest)/gox -mod="readonly" \

$(version) -w -s -H=windowsgui" \
$(dest)/{{.Dir}}_{{.OS}}_{{.Arch}}" \

-osarch="windows/amd64 linux/amd64 linux/arm linux/arm64"





Makefile OS별 설정 또는 실행


# Makefile

GO_OS := $(shell go env GOOS)
GO_ARCH := $(shell go env GOARCH)

ifeq ($(GO_OS),windows)
WINDOWS_HIDE := -H=windowsgui
else
WINDOWS_HIDE :=
endif



git clone 후 커밋 전 사용자 정보 추가

--global 옵션 안 주면 기본은 --local

git config user.name "사용자명"

git config user.email "이메일주소"



git 비공개 저장소 바꿔치기

--global 옵션 안 주면 기본은 --local

git config url."https://사용자명:액세스토큰@github.com/practice-golang".insteadof \

"https://github.com/practice-golang"




끝.