go语言基础之安装go开发环境和beego
1、install go
go1.11.4.windows-amd64.msi #默认安装就可以
2、goland
goland-2018.2.2.exe 安装完成,不要运行软件。
软件下载:https://www.jetbrains.com/go/download/#section=windows (注意版本,否则激活不了)
安装路径:
D:\Program Files\JetBrains\GoLand 2018.2.2
#程序的存放目录
D:\GoFiles\src
软件激活方法:
#复制文件到下面目录中
D:\software\go开发工具\goland-2018.2.2软件和激活工具\lib\JetbrainsCrack-3.1-release-enc.jar
#修改配置文件:
在这个配置文件中增加JetbrainsCrack-3.1-release-enc.jar文件路径:
-javaagent:D:\Program Files\JetBrains\GoLand 2018.2.2\lib\JetbrainsCrack-3.1-release-enc.jar
D:\software\go开发工具\goland-2018.2.2软件和激活工具\bin\goland.exe.vmoptions
D:\software\go开发工具\goland-2018.2.2软件和激活工具\bin\goland64.exe.vmoptions
激活软件:
Activation code : www.sdbeta.com
3、安装git
Git-2.20.1-64-bit.exe
4、install beego
go get github.com/astaxie/beego
go get github.com/beego/bee
#创建项目名称
bee new word
#运行项目
bee run word
5、手工运行go报错:
D:\GoFiles\src>bee run word
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.10.0
2018/12/29 17:23:27 INFO ▶ 0001 Using 'word' as 'appname'
2018/12/29 17:23:27 INFO ▶ 0002 Initializing watcher...
can't load package: package .: no Go files in D:\GoFiles\src
2018/12/29 17:23:27 ERROR ▶ 0003 Failed to build the application: can't load
解决方法:
修改:vi main.go
package main
import (
"fmt"
_ "./routers" #修改为当前路径
"github.com/astaxie/beego"
)
func main() {
fmt.Println("hello world")
beego.Run()
}
D:\go_scripts\hello\routers
package routers
import (
"../controllers" #修改为上上一级目录
"github.com/astaxie/beego"
)
func init() {
beego.Router("/", &controllers.MainController{})
}