55

1.Go语言开发环境搭建

 5 years ago
source link: https://studygolang.com/articles/15208?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

打开 https://golang.google.cn/dl/ 这个网站,选择对应系统的安装包

Mac系统:

  • 1、首先复制/private/etc/hosts这个文件到桌面
  • 2、打开命令行 执行如下命令 cd ~open .bash_profile
  • 3、添加 export GOROOT=/usr/local/goexport PATH=$PATH 前面
  • 4、然后将 :$GOROOT/bin 添加至 export PATH=$PATH 的末尾,完成如下图
    jYZNZjN.png!web
  • 5、在命令行执行 go env 命令,如果安装成功会出现下图
    7zieian.png!web

使用IntelliJ IDEA开发Go

  • 1、下载并安装IntelliJ IDEA
  • 2、打开Preferences,选择Plugins,点击Install JetBrains plugin...,在搜索框输入Go,点击Install安装,安装完成如下图

    MfIZFf3.png!web
  • 3、打开Preferences,设置GOPATH到你的工作目录

    BF3mqqb.png!web

Hello World!程序

在项目文件夹下,新建 src/Day01/01_HelloWorld.go 文件,输入以下内容

package main

import "fmt"

func main() {
    fmt.Println("Hello World!")
}

在文件上右击,点击Run

jeUFFzz.png!web

执行结果如下图

vaieeeM.png!web

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK