Go Hone Mac OS

broken image


I help businesses understand developers 📟 Just launched Node.js CLI Automation Course 👨‍🏫 Edutainer at VSCode.pro 🎩 An award-winning GitHub Star open-source engineer & advocate 🦊 Google Developers Expert Web DevRel 🌳 Node.js foundation Community Committee Outreach Lead ️ Author of various open-source dev-tools and software libraries used by millions of developers. Run your first Go program by executing: $ go run hello.go You'll see a sweet hello, world stdout. If you wish to compile it and move it to $GOPATH/bin, then run: $ go install hello.go Since we have $GOPATH/bin added to our $PATH, you can run your program from placement: $ hello Prints: hello, world. Some References and utilities: Import a Go package.

Install Golang with Homebrew:

When installed, try to run go version to see the installed version of Go.

Setup the workspace:

Mac

Add Environment variables:

Go has a different approach of managing code, you'll need to create a single Workspace for all your Go projects. For more information consult : How to write Go Code

First, you'll need to tell Go the location of your workspace. Live (itch) (nuria) mac os.

We'll add some environment variables into shell config. One of does files located at your home directory bash_profile, bashrc or .zshrc (for Oh My Zsh Army)

Then add those lines to export the required variables

Create your workspace:

Create the workspace directories tree:

Hello world time!

Create a file in your $GOPATH/src, in my case hello.go Hello world program :

Run your first Go program by executing:

Lights out (itch) (phoenixofforce) mac os. You'll see a sweet hello, world stdout

If you wish to compile it and move it to $GOPATH/bin, then run:

Since we have $GOPATH/bin added to our $PATH, you can run your program from placement :

Needy nebula mac os. Prints : hello, world Lambo arcade mac os.

Some References and utilities:

Import a Go package:

You can create Go package, as well importing shared ones. To do so you'll need to use go get command

The command above should import github.com/gorilla/mux Go package into this directory $GOPATH/src/github.com/gorilla/mux Guildmaster story mac os.

Go Hone Mac Os X

You can then use this package in your Go programs by importing it. Example: Count logica mac os.

Format your Go code

Go has a tool that automatically formats Go source code.

OR

Godoc : The documentation tool

Using the godoc command, you can generate a program documentation.

Go Hone Mac Os Update

You need to respect some spec in order to document using godoc. You can read more about : godoc Documenting Go code

Discovering more the language:

Go Hone Mac Os Catalina

The following interactive tutorial will let you discover Golang world : A tour of Go





broken image