Go项目使用Make工具编译 发表于 2019-08-10 | 简单的理解Make命令就是执行Makefile文件里面的shell命令,只是给出来了一套标准规范方便管理 1234567891011121314151617181920212223242526272829303132333435363738$ cat Makefile# Go parametersGOCMD=goGOBUILD=$(GOCMD) buildGOCLEAN=$(GOCMD) cleanGOTEST=$(GOCMD) testGOGET=$(GOCMD) getBINARY_NAME=adminBINARY_MAC=$(BINARY_NAME)_macBINARY_UNIX=$(BINARY_NAME)_unixBINARY_WIN=$(BINARY_NAME)_win.exeall: rundefault: $(GOBUILD) -o $(BINARY_NAME) -vbuild-mac: $(GOBUILD) -o $(BINARY_MAC) -vbuild-linux: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_UNIX) -vbuild-win: CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BINARY_WIN) -vtest: $(GOTEST) -v ./...clean: $(GOCLEAN) rm -f $(BINARY_NAME) rm -f $(BINARY_UNIX) rm -f $(BINARY_WIN) rm -f $(BINARY_MAC)run: $(GOBUILD) -o $(BINARY_NAME) -v ./$(BINARY_NAME) 学习参考 https://www.gnu.org/software/make/manual/make.html http://www.ruanyifeng.com/blog/2015/02/make.html