zoukankan      html  css  js  c++  java
  • 后端程序员之路 52、A Tour of Go-2

    # flowcontrol
        - for
            - for i := 0; i < 10; i++ {
            - for ; sum < 1000; {
            - For is Go's "while" - for sum < 1000 {
            - Forever - for {
        - if
            - if x < 0 {
            - } else {
            - if v := math.Pow(x, n); v < lim {
        - switch
            - switch os := runtime.GOOS; os {
            - A case body breaks automatically
            - fallthrough
        - defer
            - A defer statement defers the execution of a function until the surrounding function returns.
            - defer fmt.Println("world")
            - Deferred function calls are pushed onto a stack(LIFO)

    # moretypes
        - Pointers - var p *int
        - Structs
            - type Vertex struct {
            - v := Vertex{1, 2}
        - Arrays
            - var a [10]int
            - primes := [6]int{2, 3, 5, 7, 11, 13}
        - Slices
            - var s []int = primes[1:4]
            - A slice does not store any data, it just describes a section of an underlying array.
            - q := []int{2, 3, 5, 7, 11, 13}
            - var a [10]int -> a[0:10] == a[:10] == a[0:] == a[:]
            - printSlice fmt.Printf("len=%d cap=%d %v ", len(s), cap(s), s)
            - The zero value of a slice is nil.
            - a := make([]int, 5)  // len(a)=5 || b := make([]int, 0, 5) // len(b)=0, cap(b)=5
            - Slices of slices - board := [][]string{
            - for i, v := range pow { || for i := range pow { || for _, value := range pow {
        - Maps
            - m[key] = elem
            - elem = m[key]
            - delete(m, key)
            - elem, ok = m[key]
        - Function values
            - hypot := func(x, y float64) float64 {
            - return func(x int) int {

  • 相关阅读:
    关于工作态度
    ajax请求链接加时间戳
    自动消失的提示效果
    表设计原则
    进度展示图
    freemarker时间格式化
    Java的Thread.currentThread().getName() 和 this.getName() 以及 对象.getName()区别???
    使用Github做服务器展示前端页面
    Spring的生命周期
    输入三个字符,从小到大的顺序输出这三个字符
  • 原文地址:https://www.cnblogs.com/zapline/p/6829988.html
Copyright © 2011-2022 走看看