Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/build/gomodules.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ package build

import (
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"

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