GithubHelp home page GithubHelp logo

learn_go's Introduction

Notes

Installed using homebrew

brew install go --cross-compile-common

Did not need to set $GOROOT It is only a convention http://golang.org/doc/install#gopath

Code installed with homebrew have their bins in PATH so that was also not needed

mercurial (hg) is needed for go get might use svn, hg, git or bzr where is this config set in packages ? https://code.google.com/p/go-wiki/wiki/GoGetTools

go get code.google.com/p/go-tour/gotour go: missing Mercurial command. See http://golang.org/s/gogetcmd package code.google.com/p/go-tour/gotour: exec: "hg": executable file not found in $PATH

GOPATH

http://golang.org/doc/code.html#GOPATH

GOPATH is where downloaded code is installed

If GOPATH is not set:

go get code.google.com/p/go-tour/gotour package code.google.com/p/go-tour/gotour: cannot download, $GOPATH not set. For more details see: go help gopath

Can set GOPATH to

export GOPATH="/usr/local/var/go"

CHECK: It can be colon seperated if multiple paths are to be specified

emacs setup

install go-mode

REPL

seems like go does not provide a shell, even though there is a sandbox on the website http://stackoverflow.com/questions/8513609/does-go-provide-repl https://groups.google.com/forum/#!topic/golang-nuts/0o6sBNl1abY

Missing Ruby

  1. REPL
  2. begin-end blocks

Explicit erorr checks also seem like line-noise but have to try splitting code into smaller functions

terminology

  • packages
  • functions take parameters

Folder structure for packages

TODO: http://golang.org/doc/code.html#PackagePaths

Running Go Programs

go run hello.go

package manager aka rubygems ?

warnings

importing a package but not using it will throw a warning TODO: automatically collect a list of such warnings in a csv. maybe driven via tests

list of community code

installing code (go get)

comparisons with Ruby

no implicit returns like ruby semicolons can be used as terminators. but is not necessary

Questions

Programs start running in package main.

import ( "fmt" "math" ) fmt.Println("Happy", math.Pi, "Day") like a ruby module function. not like include ie. still has seperate namespace

By convention, the package name is the same as the last element of the import path.

List names exported by a package

After importing a package, you can refer to the names it exports. In Go, a name is exported if it begins with a capital letter. Foo is an exported name, as is FOO. The name foo is not exported.

func add(x int, y int) int { } to define a function. why not keep it like c ? TODO: read http://golang.org/doc/articles/gos_declaration_syntax.html

emacs mode for go ?

import ( "fmt" "math" ) what internal data-structure is that ?

TDD in go. what is the culture regarding tests in the community ?

how to find type of a variable ? and list of types in golang reflection in go. variables/types in current scope ? any type for "result parameter" in http://tour.golang.org/#9

what is := a, b := swap("hello", "world")

return_all.go: do not care about unused variables otherwise program does not run

learn_go's People

Contributors

deepak avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.