Learn Go with "Hello, world" programs
Tags: helloworld, go
Published: 2019-08-01 16:13:37

![Hello, world](https://cdn-images-1.medium.com/max/1600/1*l_FJULEFFnkq3803cMvqQw.png)

A "hello, world" program is a program which outputs or displays "hello, world" message. It often illustrates the basic syntax of programming language. Perhaps, this tradition was started from the book _The C Programming Language_, by Brian W. Kernighan and Dennis M. Ritchie, 1978.

Recently, mostly for fun learning, I've started writing "hello, world" program to try out Go language. I think it becomes easy to understand the code syntax and concepts, if you already know what output the code is going to have. 

In this post, I am showing you the initial list of "hello, world" programs, which I plan to keep updating with explanation and adding more over a period of time. I would be glad to hear your feedback and open to your contributions to make it a useful resource. [Github Repository](https://github.com/sahajre/hello-world-go)

## Print (traditional)

{% gist https://gist.github.com/sahajre/43983caf2104e699fea450fe3816ad39 %}

## Variables - string
{% gist https://gist.github.com/sahajre/2ddc590baae4838ddff641330e4057ea %}

## Variables - int
{% gist https://gist.github.com/sahajre/da661d9f6a2ed1e13c45ff4cac64fa95 %}

## Variables - boolean
{% gist https://gist.github.com/sahajre/fd999aed2505ee346f2c1d84fd9d8035 %}

## Short assignment
{% gist https://gist.github.com/sahajre/79230de09fb9d8cddad5635b9d737dc5 %}

## Constant
{% gist https://gist.github.com/sahajre/95b58a3df002c5e9312a09c06b343795 %}

## if condition
{% gist https://gist.github.com/sahajre/fca84ed3b5c6176c81fff2c46502d934 %}

## for loop
{% gist https://gist.github.com/sahajre/55287408faf457bdb951b91f75ce8776 %}

## switch 
{% gist https://gist.github.com/sahajre/70ee19676d4321c01c889302a7e789d3 %}

## switch with fallthrough
{% gist https://gist.github.com/sahajre/01df16fd31d9eb6c87438cd11495f680 %}

## switch default
{% gist https://gist.github.com/sahajre/129e2781813708038b4fc39b08e15576 %}

## break in for loop
{% gist https://gist.github.com/sahajre/d78d76530e0930192fe641b14a76f5a2 %}

## continue in for loop
{% gist https://gist.github.com/sahajre/e11e83d8e11b36e71001c07990e283a0 %}

## Array
{% gist https://gist.github.com/sahajre/138decc907a4b5b7369c3f9d109d5ee1 %}

## Slice
{% gist https://gist.github.com/sahajre/73dd5b6d8eeba790ec44be3d3e0ab8de %}

## Channel - Buffered
{% gist https://gist.github.com/sahajre/13b6dcc369b32ced20f7ccd2c3b049f4 %}

## Channel - Unbuffered
{% gist https://gist.github.com/sahajre/b8cfab258f29e0972d3de5ed27d5d9d8 %}

## function
{% gist https://gist.github.com/sahajre/0420b1b9c3c65deeebcf29395fc66c63 %}

## init()
{% gist https://gist.github.com/sahajre/6dbcebf6b01fc1236e2f3bd66ebc69ab %}

## init() order - multiple files
{% gist https://gist.github.com/sahajre/190a8ffb0137055eedcb2df1a4d774a2 %}
{% gist https://gist.github.com/sahajre/a8e9285877dc93495569d3a93aec823a %}

## Closure
{% gist https://gist.github.com/sahajre/71f08b14624daf426c8b740bbae6e430 %}

## defer
{% gist https://gist.github.com/sahajre/3cb128e82b6d02a662508c47ec2df3ba %}

## Error
{% gist https://gist.github.com/sahajre/ea9e58ad67a4037329b30c7f58366bb1 %}

## Goroutines
{% gist https://gist.github.com/sahajre/498f156b7a56885aa04a4d7a0b79b0dc %}

## Interface
{% gist https://gist.github.com/sahajre/65295b3f24967d26a40726db3aa5a9b6 %}

## map
{% gist https://gist.github.com/sahajre/6dc9a476c7b27f7b9c6e050e932ef6d7 %}

## Pointers
{% gist https://gist.github.com/sahajre/72c9c2f525a727b70c3857cd7e2476b5 %}

## range
{% gist https://gist.github.com/sahajre/08a64bbbd7852a8cbbe21cbb16d53fda %}

## return
{% gist https://gist.github.com/sahajre/e0cd49d2174e827dcc07ef0b400a4432 %}

## struct
{% gist https://gist.github.com/sahajre/e2bc41d2bf3c4ecbfd885a4a0aec450d %}

## struct embedding
{% gist https://gist.github.com/sahajre/2b4f8b25623c110a5aaf5cce00e73722 %}

## JSON
{% gist https://gist.github.com/sahajre/77b78e1bffc841ea45df12d36fae800d %}

## UTF-8
{% gist https://gist.github.com/sahajre/05c1db94ff3cbaf98b522b0cae525b3c %}

## Variadic arguments
{% gist https://gist.github.com/sahajre/b7884baffc72f66e29d0eef38d2e41a9 %}

## String replace
{% gist https://gist.github.com/sahajre/3a3b7ef424899d36c3210630d508e8f5 %}

## Web
{% gist https://gist.github.com/sahajre/8e05971323f43492dd98f3d0d485bbf0 %}