windows平台国内Go语言环境的搭建以及Gin框架的安装

简介: gin环境配置经验贴,在国内网络环境下通过国内代理服务器完成go环境配置

Go的安装

首先需要在官网Golang.google.cn下载.msi 后缀(在下载列表中可以找到该文件,如go1.4.2.windows-amd64.msi)的安装包来安装。

默认情况下 .msi 文件会安装在 c:\Go 目录下。你可以将 c:\Go\bin 目录添加到 Path 环境变量中。添加后你需要重启命令窗口才能生效。

安装成功后在命令行窗口执行命令

go

将会出现go的命令信息

Go is a tool for managing Go source code.

Usage:

        go <command> [arguments]

The commands are:

        bug         start a bug report
        build       compile packages and dependencies
        clean       remove object files and cached files
        doc         show documentation for package or symbol
        env         print Go environment information
        fix         update packages to use new APIs
        fmt         gofmt (reformat) package sources
        generate    generate Go files by processing source
        get         add dependencies to current module and install them
        install     compile and install packages and dependencies
        list        list packages or modules
        mod         module maintenance
        run         compile and run Go program
        test        test packages
        tool        run specified go tool
        version     print Go version
        vet         report likely mistakes in packages

Use "go help <command>" for more information about a command.

Additional help topics:

        buildmode   build modes
        c           calling between Go and C
        cache       build and test caching
        environment environment variables
        filetype    file types
        go.mod      the go.mod file
        gopath      GOPATH environment variable
        gopath-get  legacy GOPATH go get
        goproxy     module proxy protocol
        importpath  import path syntax
        modules     modules, module versions, and more
        module-get  module-aware go get
        module-auth module authentication using go.sum
        module-private module configuration for non-public modules
        packages    package lists and patterns
        testflag    testing flags
        testfunc    testing functions

Use "go help <topic>" for more information about that topic.

环境变量GO111MODULE的修改

在安装第三方包的时候,由于网络问题golang.org在国内无法正常使用,导致我们无法使用第三方包管理工具,因此可以通过修改系统环境变量将golang.org切换至国内CDN。

windows下,执行如下命令

$env:GO111MODULE="on" 

go.mod是一个go项目的依赖管理文件,关于go.mod的问题此处不再拓展,这里面GO111MODULE的参数是这是项目与go.mod的关系,可选 auto onoffauto 根据是否在 src 下自动判定, on 只用 go.mod , off 只用 src,此处参数on可以设置为on或者auto

国内CDN的切换

可以通过设定GOPROXY环境变量来实现国内CDN的切换,可以通过执行下面任一命令切换至七牛云,阿里云或是官方

$env:GOPROXY="https://goproxy.cn,direct"   #七牛云
$env:GOPROXY="https://mirrors.aliyun.com/goproxy/,direct"   #阿里云
$env:GOPROXY="https://goproxy.io,direct"  #官方

Gin的安装

执行命令来完成Gin的安装

go get -u -v github.com/gin-gonic/gin
目录
相关文章
|
8月前
|
人工智能 JavaScript 开发工具
极速上手!Claude Code 原生支持 Windows 免WSL安装教程
Claude Code 现已支持 Windows 原生运行,无需 WSL 配置。本文提供详细安装教程,涵盖 Node.js 环境验证、Git 安装及 Claude Code 配置步骤,助你快速上手这一强大 AI 编程工具。
11874 13
|
8月前
|
存储 虚拟化 Windows
VMware安装Windows10
本案例介绍了在Windows系统上使用VMware Workstation 17.5 Pro安装配置Windows 10虚拟机的详细步骤,包括所需设备、软件下载链接、虚拟机设置及系统安装全过程。
6281 134
VMware安装Windows10
|
8月前
|
消息中间件 缓存 NoSQL
Redis各类数据结构详细介绍及其在Go语言Gin框架下实践应用
这只是利用Go语言和Gin框架与Redis交互最基础部分展示;根据具体业务需求可能需要更复杂查询、事务处理或订阅发布功能实现更多高级特性应用场景。
492 86
|
9月前
|
Ubuntu Unix Linux
在Windows上轻松安装和使用Ubuntu的方法详解
继续点击“Continue”按钮以继续安装流程,随后选择清理磁盘并安装操作系统的选项。 接下来,在安装过程中,你需要选择时区。为了与你的地理位置相匹配,请选择中国上海作为你的时区设置。 在安装过程中,你还需要设置计算机的名称以及账号密码。请务必牢记这些信息,因为它们将作为你登录系统的凭证。
|
7月前
|
安全 Ubuntu iOS开发
Nessus Professional 10.10 Auto Installer for Windows - Nessus 自动化安装程序
Nessus Professional 10.10 Auto Installer for Windows - Nessus 自动化安装程序
289 3
Nessus Professional 10.10 Auto Installer for Windows - Nessus 自动化安装程序
|
7月前
|
SQL 安全 Linux
Metasploit Pro 4.22.8-20251014 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-20251014 (Linux, Windows) - 专业渗透测试框架
404 1
Metasploit Pro 4.22.8-20251014 (Linux, Windows) - 专业渗透测试框架
|
7月前
|
Linux 网络安全 iOS开发
Metasploit Framework 6.4.95 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.95 (macOS, Linux, Windows) - 开源渗透测试框架
828 1
Metasploit Framework 6.4.95 (macOS, Linux, Windows) - 开源渗透测试框架
|
8月前
|
安全 Linux 网络安全
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
486 2
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
|
8月前
|
Linux 网络安全 iOS开发
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
549 1
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
|
7月前
|
JavaScript 前端开发 Java
【GoWails】Go做桌面应用开发?本篇文章带你上手Wails框架!一步步带你玩明白前后端双端的数据绑定!
wails是一个可以让你使用Go和Web技术编写桌面应用的项目 可以将它看作Go的快并且轻量级的Electron替代品。可以使用Go的功能,并结合现代化UI完成桌面应用程序的开发
1423 5