My First Go Lang on Mint

Install Go Lang other OS
https://golang.org/doc/install

$ sudo apt-get install gccgo-go

$ go env
GOARCH=”amd64″
GOBIN=””
GOCHAR=”6″
GOEXE=””
GOHOSTARCH=”amd64″
GOHOSTOS=”linux”
GOOS=”linux”
GOPATH=””
GORACE=””
GOROOT=”/usr”
GOTOOLDIR=”/usr/lib/gccgo/tool”
TERM=”dumb”
CC=”gcc”
GOGCCFLAGS=”-g -O2 -fPIC -m64 -pthread”
CXX=”g++”
CGO_ENABLED=”1″

$ export GOPATH=$HOME/Downloads/go
$ go env
GOARCH=”amd64″
GOBIN=””
GOCHAR=”6″
GOEXE=””
GOHOSTARCH=”amd64″
GOHOSTOS=”linux”
GOOS=”linux”
GOPATH=”/home/adull/Downloads/go”
GORACE=””
GOROOT=”/usr”
GOTOOLDIR=”/usr/lib/gccgo/tool”
TERM=”dumb”
CC=”gcc”
GOGCCFLAGS=”-g -O2 -fPIC -m64 -pthread”
CXX=”g++”
CGO_ENABLED=”1″

$ nano hello.go
—————————-
package main

import “fmt”

func main() {
fmt.Printf(“Hello, Nano\n”)
}
—————————-
$ go build hello.go
$ ./hello
Hello, Nano

$ nano helloport3000.go
—————————-
package main

import (
“net/http”
)

func response(rw http.ResponseWriter, request *http.Request) {
rw.Write([]byte(“Hello Nano.”))
}

func main() {
http.HandleFunc(“/”, response)
http.ListenAndServe(“:3000”, nil)
}
—————————-

$ ./helloport3000

$ curl localhost:3000
Hello Nano.

Screenshot at 2016-02-29 14:41:52

Screenshot at 2016-02-29 14:42:18

 

Advertisements

About NanoSoftTech

NanoSoftTech
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s