這篇文章主要講解了“golang語言項目是如何配置Gitlab CI的”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“golang語言項目是如何配置Gitlab CI的”吧!
站在用戶的角度思考問題,與客戶深入溝通,找到興隆網(wǎng)站設(shè)計與興隆網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:網(wǎng)站設(shè)計制作、成都網(wǎng)站設(shè)計、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、空間域名、網(wǎng)頁空間、企業(yè)郵箱。業(yè)務(wù)覆蓋興隆地區(qū)。
使用golangci-lint 檢查代碼
編譯代碼
部署二進(jìn)制
主要 GOPROXY設(shè)置
before_script: - echo "before_script" - git version - go env -w GOPRIVATE=code.haiziwang.com - mkdir -p .go - go version - go env -w GO111MODULE=on - go env -w GOPROXY="https://goproxy.io,direct"
默認(rèn)集成了很多開箱即用的linter
https://golangci-lint.run/
golangci-lint: image: golangci/golangci-lint:v1.27.0 stage: lint extends: .go-cache allow_failure: true script: - golangci-lint run -v
allow_failure 表示失敗了可以繼續(xù)跑后續(xù)的job
compile: stage: build extends: .go-cache script: - go mod download - go build -race -o $OUTPUT_NAME artifacts: paths: - $OUTPUT_NAME
.go-cache: variables: GOPATH: $CI_PROJECT_DIR/.go cache: paths: - .go/pkg/mod/
# This file is a template, and might need editing before it works on your project. image: hub-mirror.c.163.com/library/golang:latest .go-cache: variables: GOPATH: $CI_PROJECT_DIR/.go cache: paths: - .go/pkg/mod/ variables: OUTPUT_NAME: helloworld-app stages: - lint - build - deploy before_script: - echo "before_script" - git version - go env -w GOPRIVATE=code.haiziwang.com - mkdir -p .go - go version - go env -w GO111MODULE=on - go env -w GOPROXY="https://goproxy.io,direct" golangci-lint: image: golangci/golangci-lint:v1.27.0 stage: lint extends: .go-cache allow_failure: true script: - golangci-lint run -v compile: stage: build extends: .go-cache script: - go mod download - go build -race -o $OUTPUT_NAME artifacts: paths: - $OUTPUT_NAME deploy-dev: stage: deploy script: - echo "deploy dev environment"
感謝各位的閱讀,以上就是“golang語言項目是如何配置Gitlab CI的”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對golang語言項目是如何配置Gitlab CI的這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!