> 文章列表 > go+vue

go+vue

go+vue

go+vue

  • 技术选择
    • 入坑理由
      • 需要搭建前后端,Java 0 基础 ,环境容易出现问题;GO上手快,问题少
      • 推荐:【七米】
          • 代码
          • 博客
  • 搭建Go语言开发环境
    • 下载 并 安装
    • 检查是否安装好?
    • GOPROXY 非常重要(帮你下载国外、GitHub代码)
    • VScode
      • 插件
        • chinese
        • go
    • 新建项目
      • 错误提示,直接点【install】
      • go mod init
      • 编写程序 hello world
      • 编译 go build
      • 执行 .\\xxx.exe
      • 【终端】【选择默认配置文件】
      • 终端 之间 切换
      • 跨平台编译
      • go mod tidy 帮你分析 你的依赖 是否 都在 .mod 中 require
        • 执行 go mod tidy , 下载第三方包
        • 并 帮你 引入 第三方包
        • 需要先 保存一下 Ctrl + S , 执行 go mod tidy 才有效
        • 下载第三方库

技术选择

入坑理由

需要搭建前后端,Java 0 基础 ,环境容易出现问题;GO上手快,问题少

go+vue
go+vue
看到有人推【七米】,所以。。。
go+vue

推荐:【七米】

代码

https://github.com/Q1mi/go_tutorial

博客

https://liwenzhou.com/
go+vue
https://www.liwenzhou.com/posts/Go/golang-menu/
go+vue
https://www.liwenzhou.com/posts/Go/install/
go+vue

搭建Go语言开发环境

下载 并 安装

下载地址
Go官网下载地址:https://golang.org/dl/
Go官方镜像站(推荐):https://golang.google.cn/dl/

检查是否安装好?

go+vue

GOPROXY 非常重要(帮你下载国外、GitHub代码)

复制、粘贴到cmd命令行、回车。
之后什么都不用做,cmd命令行 也没有输出。

go env -w GOPROXY=https://goproxy.cn,direct

go+vue

VScode

插件

chinese

go+vue
第一个【简体】,安装完后,【右下角】【重启】
go+vue

go

go+vue

新建项目

错误提示,直接点【install】

非常重要!!! 如果此时VS Code右下角弹出提示让你安装插件,务必点 install all 进行安装。

这一步需要先执行完上面提到的go env -w GOPROXY=https://goproxy.cn,direct命令配置好GOPROXY。
go+vue
go+vue
go+vue

go mod init

使用go module模式新建项目时,我们需要通过go mod init 项目名命令对项目进行初始化,该命令会在项目根目录下生成go.mod文件。例如,我们使用hello作为我们第一个Go项目的名称,执行如下命令。

go mod init hellogo mod init github.com/Q1mi/hello
后面跟, 别人 导入 你的 【包】 的名字。

go+vue
require 表示引用其他人的库
go+vue

编写程序 hello world

go+vue

编译 go build

go buildgo build -o  Out_Name.exe

生成可执行文件 hello.exe
go+vue

执行 .\\xxx.exe

只有一个go文件时,临时编译并执行,不生产exe文件
go run main.gowindows   ——  powershell.\\xxx.exewindows   ——  cmdxxx.exelinux、mac
./xxx.exe  

看清楚【终端】是 powershell 还是 cmd
go+vue

go+vue

go+vue

【终端】【选择默认配置文件】

go+vue
go+vue

终端 之间 切换

go+vue

跨平台编译

cmd 中 设置环境变量
go+vue
不能在 windows 执行, 只能在 Linux 上执行
go+vue

go mod tidy 帮你分析 你的依赖 是否 都在 .mod 中 require

cmd中执行go mod tidy

执行 go mod tidy , 下载第三方包

先 import , 并在代码中调用
再执行,go mod tidy

go+vue
go+vue

并 帮你 引入 第三方包

go+vue

需要先 保存一下 Ctrl + S , 执行 go mod tidy 才有效

go+vue

下载第三方库

go get github.com/q1mi/hello

go+vue