:Q ZmB+F _272`2M+2p2`bBQM ↵ Basic Types Slices Maps Channels Type Declarations //struct type type myType struct { embeddedType protectedMember int PublicMember string } //type type intList []int Functions func returnNumberOne() int { return 1 } // multiple return values func returnTwoInts() (int,int) { return 2,3 } // methods have receievers func (t *myType) getProt() int { return t.protectedMember }

type protGetter interface { // function signatures only getProt() int } Operators * & » & > >= x

<&^

precedence

+ - ! ^ * / % « + - | ^ == != < <= && || ^x = bitwise compliment of

Structure - Exectutable

var num int // declare an integer var num int = 1 // declare & initialize var num = 1 // type inferred num := 1 // short declaration var num, foo int = 1, 2 // multiple // Unicode works var 名 = "アラスカ" // constant const name = "golang" // group-declaration var ( foo int bar int = 1 baz = 2 ) const ( fooConst = iota // 0 barConst // 1 bazConst = "Baz" ) // camelCase when multi-word myFavoriteRodent = "gopher" // identifiers with uppercase first // letters are exported const PackageName = "my package" var BadIdea = "mutate from anywhere!"

package main import ( "pkg" "pkg2" ) import "fmt" //or one per-line const ( numberOne = 1 ) const hello = "Hello, 世界" //main.main required for executable func main() { // Code }

Short Declaration

Interfaces

Unary Multiplication Addition Comparison Logical

Declaration

// Can only use in function body x := aFunction() // type inferred // can "re-declare" with at least one // new variable var y int x, z := 1, 2 // ok x, y := 3, 4 // ERROR // creates block-local variables for i:= 0 ; i < 10; i++ { fmt.Println(i) } fmt.Println(i) // ERROR // beware of shadowing Iota

Structure - Package package mylib func CallMeFromOutside Format verbs Simpler than Cās MOAR TABLE

package anothermain import ( "fmt" ) func main() { fmt.Println("Gopher, save me") }

Go Quick Reference Go Quick Reference Go Quick Reference - GitHub

Structure - Package package mylib func CallMeFromOutside. Format verbs. Simpler than Cās. MOAR TABLE package anothermain import (. "fmt". ) func main() {.

191KB Sizes 11 Downloads 204 Views

Recommend Documents

Log4j Quick Reference Card - GitHub
log4j.appender.socket.port=10005 log4j.appender.socket.locationInfo=true log4j.logger.com.my.app=DEBUG. Level. Description. ALL. Output of all messages.

CustomGuide Quick Reference
To Delete a Message: Select the message and ... http://login.customguide.com/HancockCountySchools ... from the contextual menu, and select Clear Flag.

Know Your Customer: Quick Reference Guide - PwC
Jan 1, 2014 - Key sources of practical guidance with regard to AML requirements .... an account opened in the customer's name with a credit institution.

Quick Reference Sheet v2.1.pdf
Overload Bonus 100% Armor HP 100%. Bomb/Smrt Bomb Dmg100% Signature Rad. -50%. Smart Bomb Rng 100% Small Wp. Dmg 200%. EWAR Types.

Subaward Invoicing Quick Reference Guide_Jan2015.pdf ...
Page 1 of 2. NYU Program Services Oce. FAQs. What is flextecs? The subaward invoicing system. uses a software called flextecs to. manage the payments of.

2017 Quick Reference letter size.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. 2017 Quick Reference letter size.pdf. 2017 Quick Reference letter size.pdf. Open. Extract. Open with. Sign I