Go Reference, Cheatsheet

By pjain      Published July 29, 2019, 2:18 a.m. in blog Programming   


  • Comment // / /
  • No semi-colon necessary if newline - can add it!

Types, operators, strings

  • Integers +-int
  • Float 124.0 0.000123 Go has two floating point types: float32 and float64
  • complex64 and complex128
  • NaN, for things like 0/0)
  • Positive and negative infinity. (+∞ and −∞)

  • Operators

    • addition
    • subtraction
    • multiplication / division % remainder
  • Logical true false && and || or ! not

Vars - STATIC TYPED and constants

  • have a type
  • assigned a value
  • Names must start with a letter and may contain letters, numbers or the _ (underscore) symbol.
  • convention to use lower camel case like dogsName var x string x = "first " fmt.Println(x) x = x + "second" fmt.Println(x)

  • create and assign - type inferred x := "Hello World"

  • assign = x = 1 x = x+2 # x += 2 y = 3

  • equality == x == y # true

  • Note it is type violation for var changing type x := "first "; y := 2 # x = 2 # ERROR type changed .. x = "second"; y = 3 fmt.Println(x,y)

  • vars are mutable

  • Shorthand to define Multiple Variables = Use the keyword var (or const) followed by parentheses with each variable on its own line.

    var ( a = 5 b = 10 c = 15 )

  • constants = immutables

    const x string = "Hello World" x = "Some other string"

    Results in a compile-time error: .\main.go:7: cannot assign to x

  • var scope

  • At outer level - vars can be accessed insude functions ..


Sequence of characters with a definite length used to represent text. Go strings are made up of individual bytes, usually one for each character. Use "

backticks allow multi-line strings

Escape char \n \t etc

"Hello World"
len("Hello")  #5
fmt.Println("Hello " + "World")  # concat
  • String index starts at 0, treated as objects "Hello World"[1] # e

  • Multibyte, Unicode Characters from other languages like Chinese are represented by more than one byte

control flow

  • for i := 1 for i <= 10 { fmt.Println(i) i = i + 1 }

    for i := 1; i <= 10; i++ { ... }

  • if if i % 2 == 0 { // even } else { //or else if // odd }

  • switch - can take any type - strings or numbers .. switch i { case 0: fmt.Println("Zero") case 1: fmt.Println("One") case 2: fmt.Println("Two") case 3: fmt.Println("Three") case 4: fmt.Println("Four") case 5: fmt.Println("Five") default: fmt.Println("Unknown Number") }


  • Print() Println()

  • Scanf fmt.Print("Enter a number: ") var input float64 fmt.Scanf("%f", &input) output := input * 2 fmt.Println(output)


Go doesn't have classes but an intro at .. https://sites.google.com/site/gopatterns/object-oriented/classes


Comment 1 by yeezy boost 350 v2 June 4, 2020, 4:11 p.m.

I together with my guys appeared to be reviewing the excellent strategies on the website then the sudden got an awful suspicion I had not expressed respect to the site owner for those tips. These men happened to be so very interested to read through them and have in effect simply been enjoying these things. Thanks for getting indeed accommodating and for going for such essential guides millions of individuals are really wanting to learn about. My very own honest apologies for not expressing appreciation to you sooner.
yeezy boost 350 v2 [url=http://www.yeezyboost-350v2.us.com]yeezy boost 350 v2[/url]

Comment 2 by nike vapormax June 6, 2020, 9:09 p.m.

I would like to show appreciation to this writer just for rescuing me from this problem. After looking out through the world wide web and meeting principles which were not helpful, I thought my life was gone. Existing without the strategies to the difficulties you've fixed by way of your entire guide is a serious case, and ones which may have negatively affected my entire career if I hadn't encountered your site. Your personal competence and kindness in handling the whole lot was vital. I'm not sure what I would have done if I had not encountered such a thing like this. It's possible to at this moment look ahead to my future. Thanks a lot very much for this specialized and effective help. I will not think twice to recommend your web blog to any individual who ought to have assistance on this problem.
nike vapormax

Comment 3 by kd shoes June 9, 2020, 12:34 a.m.

I as well as my buddies happened to be examining the excellent pointers on the blog and so suddenly I got a terrible suspicion I never expressed respect to the blog owner for those tips. These women ended up for this reason stimulated to study all of them and have now extremely been taking advantage of these things. Thank you for turning out to be well considerate and then for considering certain perfect topics millions of individuals are really desperate to know about. My personal honest regret for not expressing appreciation to earlier.
kd shoes

Comment 4 by adidas yeezy June 11, 2020, 1:26 p.m.

I needed to create you the bit of note to give many thanks once again regarding the fantastic tricks you've provided at this time. It is so incredibly open-handed with you to provide extensively exactly what a lot of folks would have distributed as an e book in order to make some profit for themselves, especially now that you might have tried it in case you wanted. Those secrets in addition served like a easy way to fully grasp that the rest have a similar zeal similar to mine to grasp much more in terms of this problem. I know there are lots of more pleasant instances up front for individuals who start reading your blog.
adidas yeezy

Comment 5 by kyrie shoes June 13, 2020, 12:39 p.m.

I precisely needed to thank you very much again. I'm not certain what I would have worked on without the type of opinions provided by you on such subject matter. It became a real traumatic dilemma in my circumstances, but discovering this well-written technique you resolved that made me to jump over fulfillment. Now i'm grateful for your advice and as well , trust you are aware of a great job you are carrying out educating many others through a blog. I am sure you've never got to know any of us.
kyrie shoes

Comment 6 by yeezy boost 350 June 16, 2020, 7:47 p.m.

I simply desired to thank you so much once more. I'm not certain what I could possibly have achieved without the actual solutions shown by you over this industry. This has been an absolute frustrating case in my position, but witnessing a new well-written avenue you resolved the issue forced me to weep with gladness. Extremely thankful for this support and as well , hope you are aware of an amazing job you happen to be providing educating men and women thru a web site. I'm certain you haven't met any of us.
yeezy boost 350

Comment 7 by kyrie 6 June 24, 2020, 1:05 a.m.

I have to show some appreciation to you just for bailing me out of this type of trouble. Right after scouting throughout the search engines and obtaining methods which are not pleasant, I figured my life was done. Being alive minus the answers to the problems you've fixed by way of this website is a crucial case, as well as the kind that might have in a negative way affected my career if I hadn't encountered your web page. Your own personal talents and kindness in maneuvering every item was very useful. I don't know what I would've done if I had not encountered such a solution like this. I can at this time relish my future. Thank you so much for this professional and result oriented guide. I will not hesitate to recommend your web site to anyone who would like counselling on this situation.
kyrie 6

Comment 8 by kd shoes June 27, 2020, 1:26 p.m.

I precisely wished to say thanks once more. I'm not certain the things I would've carried out without those ways shown by you on that theme. It truly was an absolute distressing case in my opinion, however , encountering the specialized way you solved it forced me to leap for joy. Now i'm happy for your help and thus have high hopes you really know what a great job that you're doing teaching most people all through your web site. Most probably you haven't got to know any of us.
kd shoes

Comment 9 by yeezy boost 350 June 30, 2020, 9:06 a.m.

I am also commenting to let you know of the awesome encounter my friend's daughter experienced visiting your webblog. She realized too many issues, which include how it is like to have an excellent giving spirit to have men and women just comprehend some tricky subject areas. You actually did more than my expectations. Many thanks for rendering the insightful, trusted, edifying and as well as cool tips about the topic to Ethel.
yeezy boost 350

Comment 10 by off white jordan 1 July 2, 2020, 9:34 p.m.

I would like to show appreciation to this writer for rescuing me from this type of predicament. Because of browsing through the online world and obtaining thoughts that were not pleasant, I figured my entire life was well over. Living without the approaches to the issues you've resolved as a result of your good site is a critical case, as well as the kind that might have in a negative way damaged my career if I hadn't come across the blog. Your good capability and kindness in dealing with every aspect was precious. I'm not sure what I would have done if I had not encountered such a point like this. It's possible to at this time look ahead to my future. Thanks a lot so much for this expert and results-oriented guide. I will not be reluctant to recommend your blog to any individual who should receive tips on this issue.
off white jordan 1

Comment 11 by red bottom shoes July 7, 2020, 10:14 p.m.

I and my friends were studying the great procedures on the website and the sudden I got a horrible suspicion I had not thanked you for those techniques. These guys were definitely absolutely very interested to see them and have pretty much been taking advantage of those things. Many thanks for getting quite helpful and for having these kinds of essential themes millions of individuals are really wanting to learn about. My personal sincere regret for not saying thanks to you sooner.
red bottom shoes

Add new comment

Similar posts

Go Sample Full Apps

Go Quickstart

Go Setup Smarts

Go Concurrency 101