- For Ubuntu: Look here
- For MacOS: Look here
- Apart from above tutorial, add the following to your .bashrc:
export GOBIN=$GOPATH/bin
- All your code (across projects) goes into one folder. So have your environment variables set up specific to where your code is.
bin
stores executables,pkg
stores external packages,src
has all your source code.
- The documentation is very well written. You're all advised to go through it.
- The Golang book is an absolute must for you to understand the fundamentals of Go.
- Similar to C
- All referred code is up on this repository.
- Hello world program
- Defining packages
- Functions inside a package must start with a capital letter. Or else they won't be accessible outside the package.
- Each package must consist of a directory along with a .go file of the same name inside the directory.
- Installing third party packages; use
go get
. An example:-
go get -u -v gopkg.in/mgo.v2
- Packages used in this tutorial -
go get -u -v github.com/gin-gonic/gin
go get -u -v github.com/jinzhu/gorm
go get -u -v github.com/jinzhu/gorm/dialects/sqlite
go get -u -v github.com/gin-contrib/cors
- To run a program:-
go run file.go
- First, install node. Then install yarn (because npm is not very nice)
- Ubuntu:
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
npm install -g yarn
yarn global add create-react-app
- MacOS:
brew install node
npm install -g yarn
yarn global add create-react-app
- Then, create a new React application by running the following:
create-react-app name_of_app
- You can run the app by running
yarn start
node_modules
contains all your external packages.package.json
is a json file that contains all the environment requirements of your project. It is similar to therequirements.txt
file we saw for python.public
stores some static content. Theindex.html
file is going to render whatever code you write. You will need to change that based on your application's design.bash yarn build
builds your code into a production ready application. The contents are stored in thebuild
directory.src
contains all of your code. This should follow a good directory structure. Read more into it over here.- Alternate structure to follow can be found here