General Notes while Taking the Course Learning Go for Web Development

Course by Larry Price on Lynda.com

Notes

  1. Install Go on Fedora
sudo dnf install golang
  1. Configure go path
mkdir -p $HOME/go
echo 'export GOPATH=$HOME/go' >> $HOME/.bashrc
source $HOME/.bashrc
  1. Check that GOPATH is set right
go env GOPATH
- this should yield /home/user/go
  1. Make project folder
cd go
mkdir project-name
cd projcet-name
  1. Create main package
vim main.go
package main

func () {
    fmt.Println("Hello, world")
}
  1. Make directory "templates" and put in file named index.html
  2. Make sqlite3 dev database
sqlite3 dev.db
  1. The Go sql package relies on us selecting a driver
go get github.com/mattn/go-sqlite3
  1. Determine sqlite3 schema
.schema
  1. Create a table in sqlite3
sqlite3 dev.db
create table books(
pk integer primary key autoincrement,
title text,
author text,
id text,
classification text
);
  1. Get Negroni Middleware
go get github.com/codegangsta/negroni
  1. Download Ace templating
go get github.com/yosssi/ace
  1. Using gorilla/mux
    Gorilla mux is a third party router
go get github.com/gorilla/mux
  1. Using go-gorp
    Gorp is a humble packet that provides a layer of abstraction between our code and the standard sql library
go get gopkg.in/gorp.v1
  1. Session management with Negroni
    Negroni-sessions is simple and gives us easy session encryption
go get github.com/goincremental/negroni-sessions
  1. Use bcrypt for Password Encryption
go get golang.org/x/crypto/bcrypt

Popular Go Web Framworks

  1. Popular Go mini framework
    goji
go get github.com/zenazn/goji
  1. More feature rich framework
    martini
go get github.com/go-martini/martini
  1. Complex framework
    revel
go get github.com/revel/revel OR
go get github.com/revel/cmd/revel

Managing Code Quality

  1. go fmt
  2. golint
  3. unit test
General Notes while Taking the Course Learning Go for Web Development
Share this