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

    #method
        - Methods
            - Go does not have classes. However, you can define methods on types.
            - func (f MyFloat) Abs() float64 {
        - Interfaces
            - type Abser interface { Abs() float64 }
            - One of the most ubiquitous interfaces is Stringer defined by the fmt package.
            - Go programs express error state with error values.
            - The io package specifies the io.Reader interface, which represents the read end of a stream of data.
            - Package image defines the Image interface

    # concurrency
        - Goroutines - go say("world")
        - Channels
            - Channels are a typed conduit through which you can send and receive values with the channel operator, <-.
            - ch := make(chan int)
            - ch <- v    // Send v to channel ch.
            - v := <-ch  // Receive from ch, and assign value to v.
            - Buffered Channels - ch := make(chan int, 100)
        - Select
            - The select statement lets a goroutine wait on multiple communication operations.
            - The default case in a select is run if no other case is ready.
            - sync.Mutex
                - mux sync.Mutex
                - c.mux.Lock()
                - defer c.mux.Unlock()

    A Tour of Go
    https://tour.golang.org/list

  • 相关阅读:
    48. Rotate Image
    47. Permutations II
    46. Permutations
    45. Jump Game II
    44. Wildcard Matching
    43. Multiply Strings
    42. Trapping Rain Water
    41. First Missing Positive
    40. Combination Sum II
    39. Combination Sum
  • 原文地址:https://www.cnblogs.com/zapline/p/6835882.html
Copyright © 2011-2022 走看看