bee icon indicating copy to clipboard operation
bee copied to clipboard

bee new command is not create application in current directory.

Open aduan opened this issue 4 years ago • 1 comments

USAGE bee new [appname]

DESCRIPTION Creates a Beego application for the given app name in the current directory.

if current directory is not in $GOPATH or $GOPATH's sub directory, bee new command is not create application in current directory, it seem to create application in $GOPATH directory.

bee new beetest
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.10.0
2020/03/13 20:15:32 WARN     ▶ 0001 You current workdir is not inside $GOPATH/src.
2020/03/13 20:15:32 DEBUG    ▶ 0002 utils.go:325 GOPATH: /Users/aduan/go
....
	currpath, _ := os.Getwd()
	currpath = filepath.Join(currpath, appname)
	for _, gpath := range gps {
		gsrcpath := filepath.Join(gpath, "src")
		if strings.HasPrefix(strings.ToLower(currpath), strings.ToLower(gsrcpath)) {
			packpath = strings.Replace(currpath[len(gsrcpath)+1:], string(filepath.Separator), "/", -1)
			return currpath, packpath, nil
		}
	}
	// In case of multiple paths in the GOPATH, by default
	// we use the first path
	gopath := gps[0]

	beeLogger.Log.Warn("You current workdir is not inside $GOPATH/src.")
	beeLogger.Log.Debugf("GOPATH: %s", FILE(), LINE(), gopath)

it will create application in current directory when current directory is in $GOPATH .

aduan avatar Mar 13 '20 12:03 aduan

求助,创建项目不成功,找不到原因 ➜ src bee new myapp


| ___
| |/ / ___ ___ | ___ \ / _ \ / _
| |
/ /| /| / _/ _| __| v1.10.0 2020/03/15 08:50:30 WARN ▶ 0001 You current workdir is not inside $GOPATH/src. 2020/03/15 08:50:30 INFO ▶ 0002 Creating application... create /User/tushanshan/go/src/myapp/ create /User/tushanshan/go/src/myapp/conf/ create /User/tushanshan/go/src/myapp/controllers/ create /User/tushanshan/go/src/myapp/models/ create /User/tushanshan/go/src/myapp/routers/ create /User/tushanshan/go/src/myapp/tests/ create /User/tushanshan/go/src/myapp/static/ panic: open /User/tushanshan/go/src/myapp/static/js/reload.min.js: no such file or directory

goroutine 1 [running]: github.com/beego/bee/utils.MustCheck(...) /Users/tushanshan/go/src/github.com/beego/bee/utils/utils.go:239 github.com/beego/bee/utils.WriteToFile(0xc000128100, 0x35, 0x46e9849, 0x160) /Users/tushanshan/go/src/github.com/beego/bee/utils/utils.go:246 +0x140 github.com/beego/bee/cmd/commands/new.CreateApp(0x4bfbee0, 0xc000020050, 0x1, 0x1, 0x0) /Users/tushanshan/go/src/github.com/beego/bee/cmd/commands/new/new.go:287 +0x11e9 main.main() /Users/tushanshan/go/src/github.com/beego/bee/main.go:75 +0x2d4 ➜ src pwd /Users/tushanshan/go/src ➜ src go env GOARCH="amd64" GOBIN="" GOCACHE="/Users/tushanshan/Library/Caches/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/User/tushanshan/go" GOPROXY="" GORACE="" GOROOT="/usr/local/go"

debugshan avatar Mar 15 '20 00:03 debugshan