Go语言开发包
下载
配置
- 先创建两个目录:goroot和gopath
- 安装刚才的msi文件,将安装目录指定为goroot
- 设置环境变量GOPATH为gopath目录
- 验证 win+r ->cmd->go env
出现如上信息则配置成功
IDE下载配置
下载
goland官方下载地址:https://www.jetbrains.com/zh-cn/go/download/
选择试用三十天(需要注册账户)
配置
file->settings 分别配置gopath和goroot
测试
创建main文件
代码
package main
import (
"fmt"
"net/http"
)
func helloWorld(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "hello world")
}
func main() {
http.HandleFunc("/", helloWorld)
http.ListenAndServe(":8080", nil)
}
启动:
go run main.go
浏览器访问