We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const x int32 = 1
var a int32 = 1
a := 1
int(x), byte(y)
package main func main() { message := "hello world" println(message) }
package main func main() { // var numbers [3]int32 = [3]int32{7, 8, 9} numbers := [3]int32{7, 8, 9} for i, n := range numbers { println(i, ":", n) } }
if
package main func main() { flag := true if flag { println("flag is on") } else { println("flag is off") } }
for
package main func main() { for i := 0; i < 5; i++ { println(i) } }
注: 不支持++i
++i
for..range
package main func main() { x := []int32{7, 8, 9} for i, n := range x { println(i, ":", n) } }
func Add(x int, y int) int { return x + y }
package main func main() { var x int32 = 7 var p *int32 = &x // p := &x println(*p) *p = 11 println(x) }
package main type Book struct { title string author string price float32 } func main() { book := Book{"title1", "author1", 19.9} println(book.title) }
package main import "time" func foo() { println("foo") } func main() { go foo() time.Sleep(1 * time.Second) println("end") }
到这里其实都非常C,在C的基础上很克制的增加了高级语法。你会很清晰的知道每个点对应C的什么痛点。
最后附上一个最简单的Gin的web app,
package main import ( "net/http" "github.com/gin-gonic/gin" ) func main() { r := gin.Default() r.GET("/", func(c *gin.Context) { c.String(http.StatusOK, "hello world") }) r.GET("/ping", func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ "message": "pong", }) }) r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080") }
go build能直接生成出单个可执行文件,没有那么多依赖,就这个比nodejs香太多了。。。
The text was updated successfully, but these errors were encountered:
Sorry, something went wrong.
No branches or pull requests
变量
const x int32 = 1
var a int32 = 1
a := 1
int(x), byte(y)
逻辑
if
for
注: 不支持
++i
for..range
函数
指针
结构
goroutine
到这里其实都非常C,在C的基础上很克制的增加了高级语法。你会很清晰的知道每个点对应C的什么痛点。
最后附上一个最简单的Gin的web app,
go build能直接生成出单个可执行文件,没有那么多依赖,就这个比nodejs香太多了。。。
The text was updated successfully, but these errors were encountered: