mirror of
https://github.com/golang/go
synced 2024-11-07 09:06:20 -07:00
cmd/go: have go work init use the -workfile flag
Change-Id: Idb4795bde699c919222953ec33fa1083798b2000 Reviewed-on: https://go-review.googlesource.com/c/go/+/385654 Trust: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
parent
3d7f836123
commit
ecf3b39c2a
@ -46,7 +46,10 @@ func runInit(ctx context.Context, cmd *base.Command, args []string) {
|
||||
// make dirs relative to workFile path before adding the paths to
|
||||
// the directory entries
|
||||
|
||||
workFile := filepath.Join(base.Cwd(), "go.work")
|
||||
workFile := modload.WorkFilePath()
|
||||
if workFile == "" {
|
||||
workFile = filepath.Join(base.Cwd(), "go.work")
|
||||
}
|
||||
|
||||
modload.CreateWorkFile(ctx, workFile, args)
|
||||
}
|
||||
|
15
src/cmd/go/testdata/script/work_init_workfile.txt
vendored
Normal file
15
src/cmd/go/testdata/script/work_init_workfile.txt
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# Test that the workfile flag is used by go work init.
|
||||
|
||||
go work init
|
||||
exists go.work
|
||||
|
||||
go work init -workfile=$GOPATH/src/foo/foo.work
|
||||
exists foo/foo.work
|
||||
|
||||
cd foo/bar
|
||||
! go work init
|
||||
stderr 'already exists'
|
||||
|
||||
# Create directories to make go.work files in.
|
||||
-- foo/dummy.txt --
|
||||
-- foo/bar/dummy.txt --
|
Loading…
Reference in New Issue
Block a user