goland 2021.2 配置go( go1.17.6)

goland 2021.2 配置go( go1.17.6),第1张

一,配置settings:

1,打开配置界面:

file->settings->Go

如图:

2,配置GOROOT,如图:

3,配置GOPATH,如图:无需配置:

4,Go Modules: 选中Enable Go modules integration

默认已选中,无需配置

说明:刘宏缔的go森林是一个专注golang的博客,
          地址:https://blog.csdn.net/weixin_43881017

说明:作者:刘宏缔 邮箱: [email protected]

二,添加configuration

点击 Add Configuration

如图:

点击 + 按钮,选择Go Build,如图:

点OK 按钮,工具栏如图:

点绿色的右三角箭头,项目启动运行

红色的方块按钮 点击 可以停止项目

三,测试效果:

1,代码:

package main
 
import (
    "github.com/gin-gonic/gin"
)
 
func main() {
 
    // 声明一个默认路由
    r := gin.Default()
 
    r.GET("/book", func(c *gin.Context) {
        c.JSON(200, gin.H{
            "message": "GET",
        })
    })
 
    r.POST("/book", func(c *gin.Context) {
        c.JSON(200, gin.H{
            "message": "POST",
        })
    })

    r.Run(":8080")
}

2,运行:

启动后的console

项目已可通过浏览器访问,如图:

四,查看goland的版本:

五,查看go的版本:
liuhongdi@lhdpcg:/data/goapp/hello$ go version
go version go1.17.6 linux/amd64

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/990839.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存