当前位置:网站首页>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 后 右键运行即可
在学习阶段,建议将配置更改,选择以文件的方式执行,否则容易出错。
边栏推荐
- 2022-07-01:某公司年会上,大家要玩一食发奖金游戏,一共有n个员工, 每个员工都有建设积分和捣乱积分, 他们需要排成一队,在队伍最前面的一定是老板,老板也有建设积分和捣乱积分, 排好队后,所有
- Kotlin basic learning 15
- What do you know about stock selling skills and principles
- NLog use
- Haute performance et faible puissance Cortex - A53 Core Board | i.mx8m mini
- 一文彻底理解评分卡开发中——Y的确定(Vintage分析、滚动率分析等)
- Oracle 常用SQL
- [yolo3d]: real time detection of end-to-end 3D point cloud input
- 【IBDFE】基于IBDFE的频域均衡matlab仿真
- FFMpeg AVFrame 的概念.
猜你喜欢
Introduction to Robotics II. Forward kinematics, MDH method
蓝桥杯单片机省赛第十二届第一场
Pandora IOT development board learning (RT thread) - Experiment 1 LED flashing experiment (learning notes)
Jetpack之LiveData扩展MediatorLiveData
The 5th Blue Bridge Cup single chip microcomputer provincial competition
How should the team choose the feature branch development mode or trunk development mode?
Fourier series
[designmode] Prototype Pattern
It took me only 3 months to jump out of the comfort zone and become an automated test engineer for 5 years
蓝桥杯单片机省赛第八届
随机推荐
The second game of the 12th provincial single chip microcomputer competition of the Blue Bridge Cup
[mv-3d] - multi view 3D target detection network
The first game of the 12th Blue Bridge Cup single chip microcomputer provincial competition
[ibdfe] matlab simulation of frequency domain equalization based on ibdfe
The second game of the 11th provincial single chip microcomputer competition of the Blue Bridge Cup
0 foundation how to learn automated testing? Follow these seven steps step by step and you will succeed
Suggestions on settlement solution of u standard contract position explosion
Basic syntax of unity script (7) - member variables and instantiation
树莓派GPIO引脚控制红绿灯与轰鸣器
UI (New ui:: MainWindow) troubleshooting
ImageAI安装
Getting started with MQ
【力扣刷题】15.三数之和(双指针);17.电话号码的字母组合(递归回溯)
蓝桥杯单片机省赛第十一届
[yolo3d]: real time detection of end-to-end 3D point cloud input
In the era of programmers' introspection, five-year-old programmers are afraid to go out for interviews
MySQL index, transaction and storage engine
蓝桥杯单片机省赛第六届
The first game of the 11th provincial single chip microcomputer competition of the Blue Bridge Cup
Network connection mode of QT