User Tools

Site Tools


golangbot_tutorial

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
golangbot_tutorial [2018/04/16 10:53]
rpjday [Constants]
golangbot_tutorial [2019/08/27 10:52] (current)
rpjday [Misc]
Line 4: Line 4:
  
 The primary focus of Golang is to make the development of highly available and scalable web apps simple and easy. The primary focus of Golang is to make the development of highly available and scalable web apps simple and easy.
 +
 ===== Misc ===== ===== Misc =====
  
 +  * "​_"​ is the "blank identifier"​
   * Concurrency   * Concurrency
   * Compiled   * Compiled
Line 13: Line 15:
   * Debuggers?   * Debuggers?
   * Code analyzers?   * Code analyzers?
 +  * Install Visual Studio (https://​code.visualstudio.com/​docs/​setup/​linux)
  
 ===== Introduction ===== ===== Introduction =====
Line 18: Line 21:
 ==== Introduction and Installation ==== ==== Introduction and Installation ====
  
-  * [[https://​golang.org/​dl/​|Download tarball]].+Advantages of Go:
  
-==== Hello World ====+  * Simple syntax(?) 
 +  * Fast compilation 
 +  * Static linking 
 +  * Concurrency (goroutines and channels) 
 +  * Garbage collection 
 +  * Simple language specification 
 +  * Tooling 
 +    * ''/​usr/​bin/​gofmt'' ​ (golang-bin package) 
 +    * ''/​usr/​bin/​golint''​ (golint package) 
 +    * ''​go help vet''​ 
 +    * ''​go help tool''​
  
-<​code>​ +Used as the basis for Docker and Kubernetes.
-$ go help +
-Go is a tool for managing Go source code.+
  
-Usage: +Third-party tooling, IDEs, etc
- +==== Hello World ====
- go command [arguments] +
- +
-The commands are: +
- +
- build ​      ​compile packages and dependencies +
- clean ​      ​remove object files and cached files +
- doc         show documentation for package or symbol +
- env         print Go environment information +
- bug         start a bug report +
- fix         ​update packages to use new APIs +
- fmt         gofmt (reformat) package sources +
- generate ​   generate Go files by processing source +
- get         ​download and install packages and dependencies +
- install ​    ​compile and install packages and dependencies +
- list        list packages +
- run         ​compile and run Go program +
- test        test packages +
- tool        run specified go tool +
- version ​    print Go version +
- vet         ​report likely mistakes in packages +
- +
-Use "go help [command]"​ for more information about a command+
- +
-Additional help topics: +
- +
- c           ​calling between Go and C +
- buildmode ​  build modes +
- cache ​      build and test caching +
- filetype ​   file types +
- gopath ​     GOPATH environment variable +
- environment environment variables +
- importpath ​ import path syntax +
- packages ​   package lists +
- testflag ​   testing flags +
- testfunc ​   testing functions +
- +
-Use "go help [topic]"​ for more information about that topic. +
-+
-</​code>​+
  
 ===== Variables, Types and Constants ===== ===== Variables, Types and Constants =====
  
 ==== Variables ==== ==== Variables ====
- 
-  * "zero value" for different variable types 
-  * inferred variable type: 
-<​code>​ 
-var age [int] = 29 
-</​code>​ 
-  * multiple variable declaration:​ 
-<​code>​ 
-var width, height [int] = 100, 50 
-</​code>​ 
  
 ==== Types ==== ==== Types ====
  
-Go does not allow automatic type promotion or conversion -- "type conversion."​ +  * Go is strict about explicit typing.
- +
-<​code>​ +
-bool (&&,​ ||) +
-string +
- +
-int8  int16  int32  int64 +
-int (32 or 64 depending) +
- +
-uint8 uint16 uint32 uint64 +
-uint (32 or 64 depending) +
- +
-uintptr +
- +
-float32 float64 +
-complex64 complex128 +
- +
-byte // alias for uint8 +
-rune // alias for int32 +
-</​code>​ +
- +
-''​%T''​ printf format specifier prints the type of something.+
  
 ==== Constants ==== ==== Constants ====
  
-<​code>​ +  ​* Value must be known at compile time 
-const i = 42 +  * Not sure what it means that "​const"​ things ​have a "default" ​type until used 
-</​code>​ +  * What does it mean that something is "untyped"?
- +
-  ​* Value assigned to ''​const'' ​must be known at compile time; cannot require any function execution. +
-  * Untyped constants ​have a //default// type associated with them and they supply ​it if and only if a line of code demands it. You can always created a typed constant if you want: +
-<​code>​ +
-const typedhello string = "Hello World" +
-</​code>​+
  
 ===== Functions and Packages ===== ===== Functions and Packages =====
  
 ==== Functions ==== ==== Functions ====
- 
-  * return type //follows// parameter list 
  
 ==== Packages ==== ==== Packages ====
Line 194: Line 127:
  
 ===== First Class Functions ===== ===== First Class Functions =====
 +
 +===== Reflection =====
 +
 +===== File Handling =====
 +
 +==== Reading files ====
 +
 +==== Writing files ====
golangbot_tutorial.1523875994.txt.gz · Last modified: 2018/04/16 10:53 by rpjday