当前位置:网站首页>Go-3-第一个Go程序
Go-3-第一个Go程序
2022-07-05 10:23:00 【hahyyy】
第一个Go程序(在Linux系统下)
新建一个文件 ~/code/example.go
// 声明该文件所在包,如果是主程序就是main
// Go语言中使用包来组织代码
// 一般一个文件夹即一个包
// 包内可以暴露类型或方法供其他包使用
package main
// 导入库
// fmt是Go语言的一个标准库/包
// 用来处理标准输入输出
import "fmt"
// main 函数是整个程序的入口,main函数所在的包名也必须为 `main`
// 主包中必须包含一个main函数
func main() {
// 调用fmt包的Println方法,在屏幕输出信息
fmt.Println("Hello World!")
}
// 一行代表一个语句结束,多个语句写在同一行,则必须使用;来人为区分
// 单行注释://
// 多行注释:/* --- */
// 标识符:同python标识符规则
运行代码
- 直接运行
- 先编译再执行
Go语言配置
配置安装源
边栏推荐
猜你喜欢
LSTM应用于MNIST数据集分类(与CNN做对比)
5G NR系统架构
Secteur non technique, comment participer à devops?
Idea create a new sprintboot project
AtCoder Beginner Contest 258「ABCDEFG」
Constrained layout flow
Blockbuster: the domestic IDE is released, developed by Alibaba, and is completely open source!
Learning notes 5 - high precision map solution
Universal double button or single button pop-up
AtCoder Beginner Contest 258「ABCDEFG」
随机推荐
Error: module not found: error: can't resolve 'xxx' in 'XXXX‘
[论文阅读] KGAT: Knowledge Graph Attention Network for Recommendation
The horizontally scrolling recycleview displays five and a half on one screen, lower than the average distribution of five
flink cdc不能监听mysql日志,大家遇到过这个问题吧?
Write double click event
小程序中自定义行内左滑按钮,类似于qq和wx消息界面那种
【DNS】“Can‘t resolve host“ as non-root user, but works fine as root
想请教一下,十大券商有哪些?在线开户是安全么?
Activity enter exit animation
Should the dependency given by the official website be Flink SQL connector MySQL CDC, with dependency added
Implementation of wechat applet bottom loading and pull-down refresh
报错:Module not found: Error: Can‘t resolve ‘XXX‘ in ‘XXXX‘
小程序框架Taro
TypeError: Cannot read properties of undefined (reading ‘cancelToken‘)
Who is the "conscience" domestic brand?
A large number of virtual anchors in station B were collectively forced to refund: revenue evaporated, but they still owe station B; Jobs was posthumously awarded the U.S. presidential medal of freedo
Interview: how does the list duplicate according to the attributes of the object?
沟通的艺术III:看人之间 之倾听
php解决redis的缓存雪崩,缓存穿透,缓存击穿的问题
NAS与SAN