Skip to content

Commit 89dbc5a

Browse files
authored
Merge pull request #237 from socket515/feature/vendor
feat: 使用mod=vendor时候不应该更新go.mod文件
2 parents 5608940 + bc78941 commit 89dbc5a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/build/gomodules.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ package build
1818

1919
import (
2020
"io/ioutil"
21+
"os"
22+
"path"
2123
"path/filepath"
24+
"strings"
2225

2326
log "github.com/sirupsen/logrus"
2427
"github.com/tongjingran/copy"
@@ -50,6 +53,10 @@ func (b *Build) cpGoModulesProject() {
5053
// after the project is copied to temporary directory, it should be rewritten as
5154
// 'replace github.com/qiniu/bar => /path/to/aa/bb/home/foo/bar'
5255
func (b *Build) updateGoModFile() (updateFlag bool, newModFile []byte, err error) {
56+
// use buildflags `-mod=vendor` and exist vendor folder, should not update go.mod
57+
if _, err1 := os.Stat(path.Join(b.ModRoot, "vendor")); err1 == nil && strings.Contains(b.BuildFlags, "-mod=vendor") {
58+
return
59+
}
5360
tempModfile := filepath.Join(b.TmpDir, "go.mod")
5461
buf, err := ioutil.ReadFile(tempModfile)
5562
if err != nil {

0 commit comments

Comments
 (0)