Skip to content

Latest commit

 

History

History
195 lines (161 loc) · 3.88 KB

go.wiki

File metadata and controls

195 lines (161 loc) · 3.88 KB

Table of Contents

[topic][intro]

[---] go help

2. Freenode IRC, #go-nuts http://freenode.net/ [---]

[topic][install]

[---] 1. download https://code.google.com/p/go/wiki/Downloads?tm=2

2. extract `tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz`

3. in ~/.bashrc, insert: export PATH=$PATH:/usr/local/go/bin

4. create a sample app and compile `go run hello.go` [---]

[topic][build]

[---] set -o nounset set -o errexit set -o pipefail

go build -o apptranslator_app *.go ./apptranslator_app [---]

[topic][hello]

[---] @@@ hello.go: package main

import "fmt"

func main() { fmt.Printf("Hello, world.\n") } [---]

[topic][loop][for]

[---] 1. for row := range bigDigits[0] { - is same as - for row := 0; row < len(bigDigits[0]); row++ {

2. infinite loop for {

  /// run forever

} [---]

[topic][list]

[---] import "container/list" for e := l.Front(); e != nil; e = e.Next() { // do something with e.Value } [---]

[topic][array]

[---]

[---]

[topic][slices]

[---] func make([]T, len, cap) []T

- length and capacity len(s) == 5 cap(s) == 5

Title: slicing - Slicing does not copy the slice's data. - It creates a new slice value that points to the original array.

type sliceHeader struct {

    Length        int
    ZerothElement *byte

}

slice := sliceHeader{

    Length:        50,
    ZerothElement: &buffer[100],

} [---]

[topic][string][concat]

[---] s += "adfa" + " another "

[---]

[topic][string][to]

[---] t := strconv.Itoa(123) [---]

[topic][exec]

[---] out, err := exec.Command("sh","-c",cmd).Output()

[---]