002.golang 基础知识
发布时间:2020-12-16 19:18:41 所属栏目:大数据 来源:网络整理
导读:Go内置关键字 . . . . . break default func interface select case defer go map struct chan else goto package switch const fallthrough if range type continue for import return var Go注释方法 // :单行注释 /* */:多行注释 //当前程序的包名 pack
Go内置关键字
Go注释方法
//当前程序的包名
package main
//导入其他的包
import "fmt"
/* 由main函数作为程序入口点的启动 */
func main() {
fmt.Println("Hello world!")
}
Go程序的一般结构
//导入其他的包
import "fmt"
//导入其他的包
import (
"fmt"
"math"
)
const PI = 3.1415926
var a string = "abc"
//一般结构声明
type newType int
//结构的声明
type gopher struct{}
//接口的声明
type golang interface{}
//接口型函数的声明
type MatchFunction func(rune,rune) bool
func main() { }
fmt.Println("Hello world!")
package main
import (
fff "fmt"
)
const PI = 3.1415926
var a string = "abc"
func main() {
fff.Println(PI,a)
}
//调用第三方包的参数或函数,可以看到首字母都是大写的
fmt.Println("Hello world!") (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |