有时候还是喜欢用Makefile比较方便。这里先不论交叉编译的情况,因为交叉编译被我利用docker container代替了。只需要docker attach go进去之后make一下即可交叉编译。

GONAME=$(shell basename "$(PWD)").bin

all: build

build:
	@echo "Building $(GONAME)..."
	@-go build -o $(GONAME) && ([ $$? -eq 0 ] && echo "success" && ./$(GONAME)) || echo "go build failed"

clean:
	@echo "Cleaning"
	@- rm -rf $(GONAME)

.PHONY: build clean