Skip to content

ravi-prakash1907/golang-walkthrough

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Crash Course on golang

golang banner

I've created this repo to recollect myself for golang and have a quick recap to come back on track. This repository stores the implementation of some most common and necessary things in golang.
This repository consists of the whole golang environment along with the working directory containerized using Docker. All that you need is to have the docker installed on your machine.

Quick Set-Up

Just follow the following easy steps to run the codes present in the repository without worrying about installing the go on your system locally!

(A) Without 'docker-compose.yml'

While using very first time:

  1. Navigate to the Golang-Programs directory.
  2. Run the following command -
docker build . -t golang-tuts:1.0  

This command builds an image using the Dockerfile i.e. already present in this directory.
Here -t tags the image i.e. gives an alternative name to the image that is being built. It helps it identify the image easily rather than using its id.

Use the following command to run the assecc golang utilities on command line:

Once the image is created, we are good to go ahead to run it, whenever needed.

docker run -it --rm golang-tuts:1.0

Here:
-it stands for interactive terminal
--rm Automatically remove the container when it exits i.e. stops

As: Use the command line to run desired commands.
Put all the golang files (.go) file in src directory.


(B) Using 'docker-compose.yml'

While using very first time:

  1. Navigate to the Golang-Programs directory.
  2. Run the following command -
docker-compose up  

This command builds an image using the Dockerfile i.e. already present in this directory.
Here --no-rm used not to remove the intermediate containers that are also built during creating this image named golang-programs_golang

Use the following command to run the golang on command line:

Once the image is created, we are good to go ahead to run it, whenever needed.

docker run -it --rm golang-programs_golang

Here
-it stands for interactive terminal
--rm Automatically remove the container when it exits i.e. stops

(C) Using shell scripts

You can also execute everything just using a single shell command.
We have provided you with 2 shell scripts:

  1. build.sh :
  • it builds the image i.e. followed by running the container to provide you access to go runtime via bash
  • run sh ./build.sh
  1. run.sh :
  • it just pulls an existing image (if any) and runs it to provide you the access to go runtime via bash
  • run sh ./run.sh

Get Familiar

This go command/syntax cheatsheet can be accessed to get well aware of the initial of the golang.

Todo

There is a long way to go... I aim to add the following additional things to this repo:

  1. Detailed description (with examples) on goroutine and http server
  2. gRPC
  3. Concurrency patterns
  4. Microservices ...

Contributions are happily accepted!!


visit here for a quick walkthrough with golang

References

  1. Cheatography
  2. Derek Banas