后端程序员之路 52A Tour of Go-2

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了后端程序员之路 52A 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\n", 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 {

以上是关于后端程序员之路 52A Tour of Go-2的主要内容,如果未能解决你的问题,请参考以下文章

Spark——Chapter3:A Tour of Spark’s Toolset

Spark——Chapter3:A Tour of Spark’s Toolset

机器学习算法之旅A Tour of Machine Learning Algorithms

CHAPTER 1 ----- a tour of computer sysytems

Brief Tour of the Standard Library

新手学Python之学习官网教程(十: Brief Tour of the Standard Library)