Home - pslpune/golang-jumpstart GitHub Wiki
Index of topics
For PSL candidates in Pune who have decent exposure to programming, but are looking fwd. to get on the GoLang bandwagon. Since Go requires one to have shift in the mindset if from the C#, Javscript, python or similar background, this course is hence designed to be entirely hands-on. We would employ the piece-meal approach where we deal with topics and then subsequently do the hands on immediately following it, rather than reserving the hands-on as a addon at the last.
The course is followed by an assessment - where all the candidates would have to undergo a timeboxed handson test. For a selected few we then plan to also propose a project entailing an IoT prototype. A prototype of such nature would then have development on the complete stack - Hardware, Embedded, Cloudware, Web
Topic | Subtopics | Chapter |
---|---|---|
Preface/Intro | Origins of Go, Overview of a Go Project | |
Program structure | Names, declaration, variables, assignments, types, packages, scopes | Chapter-01 |
Basic data types | Integers, Floats, bool, strings, constants | Chapter-02 |
Composite types | Arrays, slices, maps | Chapter-03 |
Composite types ctd.. | pointers, structs | Chapter-04 |
Functions | Declarations, recursions, multiple return values, errors, function values, anonymous functions, variadic functions, defer, panic & recover | |
Methods | declarations, pointer receivers, struct embedding, values & expressions, encapsulation | Chapter-06 |
Interfaces | concept, interface types, interface satisfaction, type assertioons, type switches, Miscelleneous advice | |
Go routines & channels | concept, concurrency in go, demo, goroutines, channels, multiplexing, looping thru channels, cancellation & interrupts, handson | |
Packages & go tooling | Introduction, import paths, module declarations, blank imports, Go tool | |
Testing | go test tool, testing functions, coverage, benchmarking | |
Documentation | go doc tool | |
Assessment | A hands on timeboxed coding exercise to test your understanding | |
Live Project | Building a full stack live IoT prototype |
Tools and setup
Apart from the local environment + VSCode (which is still, surprisingly) the defacto choice of most the developers, lecturer would be using Github Codespaces as that would agnostic of the location he is from. We encourage the students to also checkout Go playground or the Better Go Playground. These are handier when it comes to get your hands dirty for the first time. Unless ofcourse you are a seasoned GoLang developer then in that case you shouldn't be in this classroom in the first place :smiley:
Origins of GoLang
Go was created as an attempt to provide a single language that combined efficient compilation, efficient execution, and ease of programming. In the last few years, Go’s rise in popularity has demonstrated that it has definitely filled a need in the software development community. By the time you are done, you will have a solid understanding of how Go might be able to help you reach your goals.
GoLang was conceived in September 2007 by Robert Greisemer, Rob Pike, Ken Thompson
all @ Google. The language was announced and became public 2009, November
. The goals of the language was to become effective and efficient in compilation and execution and effective in writing reliable robusts programs.
Golang usecases
Go is especially suitable to build
- Networked servers
- Tools & systems for programmers
- Machine learning applications
- Internet of things applications
It actually become a replacement for untyped dynamic scripting languages, cause it balances expansiveness & safet
y. In comparison to these languages
- Go runs / compiles much faster
- Suffers far few crashes due to unexpected type errors
Golang ethos
Go was actually borne out of frustration of several software systems @ Google that were suffering an explosion of complexity.
- ofcourse this problem is in no way unique to Google, but as Rob Pike put it - Complexity is multiplicative
fixing a problem by making one part of the system much more complex, slowly but surely adds complexity to other parts of the system. With a constant pressure to add features, edit code & ship code its easy to neglect simplicity.
Simplicity requires more work at the onset of the project and more discipline as we move ahead in the course of the project. With sufficient effort its possible to have a good change
accomodate without comprimising conceptual integrity
of the design.
Go project includes the language itself, tools, standard libraries, and the radical idea of simplicity. If at all I had list the features of Go here are they
- :heavy_check_mark: Garbage collection
- :heavy_check_mark: Package system
- :heavy_check_mark: First class functions Stackoverflow
- :heavy_check_mark: Lexical scope See here on stackoverflow
- :heavy_check_mark: A system call interface
- :heavy_check_mark: Immutable strings in which the text is generally encoded in UTF-8
You can see it has comparitvely less features, and is unlikely to add anymore.
If I had to list the features that aren't offered :
- :x: Implicit numeric conversions
- :x: Constructors / destructors
- :x: Operator overloading
- :x: Default parameter values
- :x: Inheritance
- :x: Generics
- :x: Exceptions
- :x: Macros
- :x: Function annotations
- :x: Thread local storage
The programming world is seemingly divided into 2 school of thoughts
- Attacking the problem from the top
- Attacking the problem from the bottom
Thats just one more way of classifying the languages.
Languages that attack the problem from the top, deal with the problem at hand at its most complex manifestation, hence need more support from standard libraries & syntactic sugar around basic construct, consequentially a feature rich language - More often than not the libraries pack a lot more code than is required. But since the code is easier to grasp and maintain its much more popular. If you are tackling the problem at highest level the tools ought to be evolved.
While languages that attack the problem from the bottom need the programmer to have a sound understanding of lower level constructs but have to write much less code to achieve the same result. Such languages are also minimalist, offer simple syntax and less prone to the problems of dependencies. More experienced programmers tend to subscribe to this school of thought. It is found that such languages have far less frills & only provide features that are utmost necessary.
Example : Lets say you had to make a chat server, Languages like C# would offer std libraries that can let you be agnostic to the lower level drudgeries (socket programmig, threads/thread pools), but do get a lot of code that is just frills and fancies from the libraries they are using. Go offers you more control letting you handle sockets and thread pools using language constructs instead of pre-written code. This makes Go code leaner but only if you know how to use those constructs!
Walkthru sample GoLang code
We need NOT get into the details of understanding what the code actually does, but this can help you see, firsthand the nature / structure of any golang project. The lecturer will take you thru all the sections one-by-one and help you build a mindmap of how a typical go code looks like.