Notice that you will have to invoke the call to flag.Parse() without which you will not be able to access the arguments.

Reflection support in Go

We take the previous example, add some code for reflection which will help us understand how reflection library may be used. Just some simple example without having to go deep. For that, read this post from the official Go blog.

So what is the type returned by flag.Arg(0) ? We will start from there and go use some functions.

The above example shows a few things:
- Creating an instance of big.Int using the NewInt() call.
- Accessing the size of the big.Int using unsafe package exported SizeOf() function
- SizeOf() returns uintptr and we convert that to integer - that is a good example of casting
- How to set bit on the big.Int using SetBit

Hash libraries in the Go "hash" package implements the Hash interface. The implementations in the standard Go library as of this time are adler32, crc32, crc64, fnv-1/fnv-1a. The above example creates an instance of FNV hash, writes a byte array to it and then gets the value through Sum32() call. You can "forget" what is written to it by Reset() function which will allow you to reuse the hash instance.

I am newly learning Go and along the way sharing some things that I learnt. If you know of a better way to accomplish what I have shared here, please feel free to comment.