Go语言 - HelloWorld

Go语言 - HelloWorld

概念

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

  • 简单、可靠、高效是其特点,Go语言支持并发,提供海量并行的支持。相比C++,Go语言中开启线程十分方便。
  • 由于这些特点,Go语言是一门专门用于巨型中央服务器的语言。
安装(Ubuntu)
  • 可以在其官网下载安装包,也可以使用apt命令安装。
sudo apt-get update
sudo apt-get install golang-go
  • 安装完成后,在终端输入go,输出如下
linduo@lindo:~/Work$ go
Go is a tool for managing Go source code.

Usage:

	go command [arguments]

The commands are:

	build       compile packages and dependencies
	clean       remove object files
	doc         show documentation for package or symbol
	env         print Go environment information
	fix         run go tool fix on packages
	fmt         run gofmt on package sources
	generate    generate Go files by processing source
	get         download and install packages and dependencies
	install     compile and install packages and dependencies
	list        list packages
	run         compile and run Go program
	test        test packages
	tool        run specified go tool
	version     print Go version
	vet         run go tool vet on packages

Use "go help [command]" for more information about a command.

Additional help topics:

	c           calling between Go and C
	buildmode   description of build modes
	filetype    file types
	gopath      GOPATH environment variable
	environment environment variables
	importpath  import path syntax
	packages    description of package lists
	testflag    description of testing flags
	testfunc    description of testing functions

Use "go help [topic]" for more information about that topic.
HelloWorld
  • hello.go
/* 包声明
 * main包表示一个可独立执行的程序
 */
package main

// 引用包,引入fmt
import "fmt"

func main() {
	// 定义变量
    var str string = "Hello World"
    // 语句
    fmt.Println(str)
}
  • 执行
go run hello.go

# 或编译为二进制

go build hello.go
./hello
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林多

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值