“Golang”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
第216行: 第216行:
  
 
https://chenyangguang.github.io/2018-11-27-ide/
 
https://chenyangguang.github.io/2018-11-27-ide/
 +
 +
 +
=easy=
 +
<pre>
 +
2) package main
 +
表示该 hello.go 文件所在的包是 main, 在 go 中,每个文件都必须归属于一个包。
 +
(3) import “fmt”
 +
表示:引入一个包,包名 fmt, 引入该包后,就可以使用 fmt 包的函数,比如:fmt.Println
 +
(4) func main() {
 +
}
 +
 +
func 是一个关键字,表示一个函数。
 +
main 是函数名,是一个主函数,即我们程序的入口
 +
</pre>
  
 
=see also=
 
=see also=
第223行: 第237行:
  
 
[https://blog.csdn.net/u013328965/article/details/103987944 Linux运行go文件]
 
[https://blog.csdn.net/u013328965/article/details/103987944 Linux运行go文件]
 
  
 
=R=
 
=R=
 
[https://blog.csdn.net/BobYuan888/article/details/104581850  国内代理安装VScode安装Go插件]
 
[https://blog.csdn.net/BobYuan888/article/details/104581850  国内代理安装VScode安装Go插件]
 
  [[category:go]]
 
  [[category:go]]

2021年12月9日 (四) 03:44的版本

learn

记得第一次安装golang 当时还在dkm 2017年吧 可惜当时太闲了 也没在当时努力学习一下golang 可惜了呢 Dec 2021

谈谈 Golang, 以及我走的一些弯路

怎么学习 Golang

https://studygolang.com/


golang快速入门

Golang 调用 Linux 命令

Go语言学习笔记 --- 指针和自增自减运算及相关注意事项

Golang注释规范

install

可以直接 apt install golang 不过下面的官方教程不错呀 
从go 1.8开始,GOPATH环境变量现在有一个默认值,如果它没有被设置。 它在Unix上默认为$HOME/go,

wget -c https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz

tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz

tar  -xvf go1.14.4.linux-amd64.tar.gz  -C /usr/local/





#加入 添加到环境变量 Dec 09 2021 
#export GOPATH=/root/go/  #(可选设置) 如果你用root运行
export GOROOT=/usr/local/go/
export PATH=$PATH:$GOROOT/bin 
export GOPATH=/home/evan/devops/go/goproject
#GOPATH=$HOEM/goproject
export GOARCH=amd64
export GOOS=linux
export GOTOOLS=$GOROOT/pkg/tool









echo 'export PATH=$PATH:/usr/local/go/bin' >>/etc/profile  && source /etc/profile

vi /etc/profile
export PATH=/usr/local/go/bin/:$PATH
#export GOPATH=/root/go/  #(可选设置) 如果你用root运行 
export GOROOT=/usr/local/go/
#export GOARCH=amd64
#export GOOS=linux
export GOTOOLS=$GOROOT/pkg/tool
#export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

#export PATH=$PATH:/usr/local/gobin

source /etc/profile


#export PATH=/usr/local/go/bin/:$PATH
#export GOPATH=/root


#以前的文章
#freebsd
 https://dl.google.com/go/go1.12.5.freebsd-amd64.tar.gz
#linux
 curl -o  go1.13.6.linux-amd64.tar.gz   https://dl.google.com/go/go1.13.6.linux-amd64.tar.gz


tar -C /usr/local -xzf go1.12.5.freebsd-amd64.tar.gz



export PATH=$PATH:/usr/local/go/bin

source /etc/profile  #如果修改的是/etc/profile
source $HOME/.profile   #如果修改的是$HOME/.profile

go version



Download and install

golang go get代理设置

golang go get代理设置

ubuntu

sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update
sudo apt install golang-go

https://github.com/golang/go/wiki/Ubuntu

IDE

VSCode

#国内代理安装vscode golang 插件 plugin
    go env -w GO111MODULE=on
    go env -w GOPROXY=https://goproxy.cn,direct

goland

进入goland的bin目录下执行./goland.sh

Goland常用快捷键 文件相关快捷键: ​ CTRL+E,打开最近浏览过的文件。 CTRL+SHIFT+E,打开最近更改的文件。 CTRL+N,可以快速打开struct结构体。 CTRL+SHIFT+N,可以快速打开文件。 代码格式化: ​ CTRL+ALT+T,可以把代码包在一个块内,例如if{…}else{…}。 CTRL+ALT+L,格式化代码。 CTRL+空格,代码提示。 CTRL+/,单行注释。CTRL+SHIFT+/,进行多行注释。 CTRL+B,快速打开光标处的结构体或方法(跳转到定义处)。 CTRL+“+/-”,可以将当前方法进行展开或折叠。 查找和定位 CTRL+R,替换文本。 CTRL+F,查找文本。 CTRL+SHIFT+F,进行全局查找。 CTRL+G,快速定位到某行。 代码编辑 ​ ALT+Q,可以看到当前方法的声明。 CTRL+Backspace,按单词进行删除。 SHIFT+ENTER,可以向下插入新行,即使光标在当前行的中间。 CTRL+X,删除当前光标所在行。 CTRL+D,复制当前光标所在行。 ALT+SHIFT+UP/DOWN,可以将光标所在行的代码上下移动。 CTRL+SHIFT+U,可以将选中内容进行大小写转化。

linux下Goland如何设置桌面快捷方式

 ln -s  /opt/goland/bin/goland.sh /usr/bin/goland #我是这种在 awesome有效 


goland打开后点击任务栏:

tools---->create desktop entry.


#我的这个应该是没效果的
cat /usr/share/applications/goland.desktop
Version=1.0
Type=Application
Name=GoLand
Icon=/opt/goland/bin/goland.png
Exec="/opt/goland/bin/goland.sh" %f
Comment=The Drive to Develop
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-goland

GO教程:安装Goland开发工具

go安装与goland破解永久版

emacs

golang快速入门[6.2]-集成开发环境-emacs详解 https://github.com/golang/go/wiki/IDEsAndTextEditorPlugins

https://emacs-china.org/t/topic/6469

https://stackoverflow.com/questions/1715464/emacs-mode-for-go#1715502

https://www.emacswiki.org/emacs/GoLangMode

Emacs中多个golang项目的配置方法

Emacs golang 配置

https://www.cnblogs.com/lienhua34/p/5838166.html

https://github.com/lienhua34/myemacs-conf

https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Blang/go

https://blog.yuantops.com/tech/emacs-config-go-dev-environ/

https://dreamerjonson.com/2019/11/24/emacs-package-for-golang/index.html

https://github.com/dominikh/go-mode.el

https://github.com/alecthomas/gometalinter

https://www.cnblogs.com/cobbliu/p/4860600.html

Emacs golang 配置


https://zhuanlan.zhihu.com/p/19902040

https://github.com/lryong/emacs-golang-conf

https://chenyangguang.github.io/2018-11-27-ide/


easy

2) package main
表示该 hello.go 文件所在的包是 main, 在 go 中,每个文件都必须归属于一个包。
(3) import “fmt”
表示:引入一个包,包名 fmt, 引入该包后,就可以使用 fmt 包的函数,比如:fmt.Println
(4) func main() {
}

func 是一个关键字,表示一个函数。
main 是函数名,是一个主函数,即我们程序的入口

see also

https://golang.google.cn/doc/install#install

https://www.runoob.com/go/go-environment.html

Linux运行go文件

R

国内代理安装VScode安装Go插件