当前位置:网站首页>Go语言介绍
Go语言介绍
2022-07-02 03:45:00 【UPythonFish】
Go语言介绍
一 Go语言介绍
Go 即Golang,是Google公司2009年11月正式对外公开的一门编程语言。
Go是静态强类型语言,是区别于解析型语言的编译型语言(静态:类型固定 强类型:不同类型不允许直接运算)。
二 Go语言特性
- 跨平台的编译性语言(能够交叉编译)
- 语法接近C语言
- 管道(channel),切片(slice),并发(routine)–》线程池+协程
- 有垃圾回收机制(GC)
- 支持面向对象和面向过程的编程模式
三 Go语言发展
go语言也是用c写的,在2009年11月7日 发布 weekly.2009-11-06,早期的版本,下面介绍几个重要go版本
- 2012年3月28日 go1 —— 稳定版版的发布
- 2015年8月19日 go1.5 —— 实现的架构变化,同时保留了和旧版本的兼容性,本次更新中移除了”最后残余的C代码”—》自举
- 2018年8月24日 go1.11 —— modules支持,摒弃掉go path的包管理
- 2020 年 2 月 go 1.14— — 现在 Go Module 已经可以用于生产环境
- 至今:1.17.6 开始支持泛型(额外操作)
go语言现在基本所有的中大型公司都在使用,并且有许多成熟的开源项目,如 docker,kubernetes 等,并且适合服务端开发,微服务方向,区块链开发 第一款开源的区块链软件是用go写的,自动化运维 docker,k8s二开,云平台等方向。因此go具有很好的发展情景,并且学习也比较简单。
四 Go开发环境搭建
4.1 go 的 sdk
下载地址:https://golang.google.cn/dl/,找到对应系统版本,下载最新版本,一直下一步即可
安装完成后,会把安装路径添加到环境变量中,在cmd窗口输入 go version 即可输出安装go版本

4.2 IDE的选择
go 的IDE 目前主流就是 goland , vscode,以及linux 上的 vim
这里选择 以goland 为主,也推荐新手使用 goland ,虽然 goland 收费,但是他功能强大并且可以破解,vscode和vim都需要自己去搭开发环境,并且全套下来也不比 goland所占空间小。
https://www.jetbrains.com/zh-cn/go/download/other.html—》2021.1 版本 可以使用无限试用插件
下载后一直下一步即可

五 第一个go程序
package main // 指定包名,任何一个go文件都要有这句话,包名可以不一样,目前必须叫main
import "fmt" //导入内置包,fmt包,只要使用了fmt包,会自动导入,goland自动导入的,如果其他编辑器,需要手动导入
func main() {
// 定义一个函数,函数名叫 main,目前必须叫main
fmt.Println("hello world") // 真正的在控制台输出 hello world,必须用双引号
}
由于go是编译性语言,和python不一样,需要先编译后执行
go build go文件名 // 编译go文件, win平台 编译成 go文件名.exe
go run go文件名字.exe // 执行文件运行,也可以直接点击运行
并且可以直接 go run go文件名 // 会自动编译并运行,但是编译后的文件,不在项目根路径下,并且运行后会删除
开发阶段使用 goland 执行
goland也提供了编译并运行,配置好go sdk 后 右键运行即可

在学习阶段,建议将配置更改,选择以文件的方式执行,否则容易出错。

边栏推荐
- Kubernetes cluster storageclass persistent storage resource core concept and use
- [designmode] builder model
- Interface debugging tool simulates post upload file - apipost
- [wireless image transmission] FPGA based simple wireless image transmission system Verilog development, matlab assisted verification
- 蓝桥杯单片机省赛第十二届第二场
- The first practical project of software tester: web side (video tutorial + document + use case library)
- Oracle viewing locked tables and unlocking
- 0基础如何学习自动化测试?按照这7步一步一步来学习就成功了
- 树莓派GPIO引脚控制红绿灯与轰鸣器
- 初识string+简单用法(二)
猜你喜欢

The 9th Blue Bridge Cup single chip microcomputer provincial competition

"Analysis of 43 cases of MATLAB neural network": Chapter 42 parallel operation and neural network - parallel neural network operation based on cpu/gpu

【DesignMode】原型模式(prototype pattern)

滴滴开源DELTA:AI开发者可轻松训练自然语言模型

接口调试工具模拟Post上传文件——ApiPost

蓝桥杯单片机省赛第五届

蓝桥杯单片机省赛第十届

Pycharm2021 delete the package warehouse list you added

Fourier series

【力扣刷题】15.三数之和(双指针);17.电话号码的字母组合(递归回溯)
随机推荐
Jetpack's livedata extension mediatorlivedata
Failed to upgrade schema, error: “file does not exist
How should the team choose the feature branch development mode or trunk development mode?
In the era of programmers' introspection, five-year-old programmers are afraid to go out for interviews
Set vscode. When double clicking, the selected string includes the $symbol - convenient for PHP operation
The 11th Blue Bridge Cup single chip microcomputer provincial competition
C语言:逻辑运算和判断选择结构例题
u本位合约爆仓清算解决方案建议
"Analysis of 43 cases of MATLAB neural network": Chapter 42 parallel operation and neural network - parallel neural network operation based on cpu/gpu
Oracle common SQL
[untitled] basic operation of raspberry pie (2)
[tips] use Matlab GUI to read files in dialog mode
Fingertips life Chapter 4 modules and packages
Cloud service selection of enterprises: comparative analysis of SaaS, PAAS and IAAs
一文彻底理解评分卡开发中——Y的确定(Vintage分析、滚动率分析等)
It took me only 3 months to jump out of the comfort zone and become an automated test engineer for 5 years
《MATLAB 神经网络43个案例分析》:第42章 并行运算与神经网络——基于CPU/GPU的并行神经网络运算
Pandora IOT development board learning (HAL Library) - Experiment 2 buzzer experiment (learning notes)
[ibdfe] matlab simulation of frequency domain equalization based on ibdfe
《西线无战事》我们才刚开始热爱生活,却不得不对一切开炮