↓ Skip to main content

Golang

Go Modules

Go Modules

·1 min
If you are like me and getting errors while trying to compile your go lang code without having a go.mod in v1.18
Fun with `goroutines`

Fun with `goroutines`

Channels are way of communication between multiple goroutines You can declare a channel and the type of content the channel will receive like below. var myChannel chan int The int above is the type of data it can receive and the data can be send using
GoLang: Hash

GoLang: Hash

·2 mins
Previously I talked about files, encoding in golang. In this LTD (learn to do) I will talk about hash package in general. https://blog.samarthya.me/wps/2021/01/30/golang-encoding/ Help # https://golang.org/pkg/hash/#Hash https://golang.org/pkg/crypto/#Hash.New https://golang.org/src/crypto/crypto.go?s=364:378#L6 https://golang.org/pkg/crypto/#pkg-subdirectories Package crypto collects common cryptographic constants. — Official golang documentation const ( MD4 Hash = 1 + iota // import golang.org/x/crypto/md4 MD5 // import crypto/md5 SHA1 // import crypto/sha1 SHA224 // import crypto/sha256 SHA256 // import crypto/sha256 SHA384 // import crypto/sha512 SHA512 // import crypto/sha512 MD5SHA1 // no implementation; MD5+SHA1 used for TLS RSA RIPEMD160 // import golang.org/x/crypto/ripemd160 SHA3_224 // import golang.org/x/crypto/sha3 SHA3_256 // import golang.org/x/crypto/sha3 SHA3_384 // import golang.org/x/crypto/sha3 SHA3_512 // import golang.org/x/crypto/sha3 SHA512_224 // import crypto/sha512 SHA512_256 // import crypto/sha512 BLAKE2s_256 // import golang.org/x/crypto/blake2s BLAKE2b_256 // import golang.org/x/crypto/blake2b BLAKE2b_384 // import golang.org/x/crypto/blake2b BLAKE2b_512 // import golang.org/x/crypto/blake2b ) Let’s try out a simple MD5 hasher.
GoLang: Hex Output

GoLang: Hex Output

·3 mins
In last few blogs I have written about reading commandline parameters reading files and using the os package. In this blog, I will combine some these items to read a file byte by byte using the bufio package func’s.
GoLang: Program Banner

GoLang: Program Banner

·2 mins
In the last blog I talked about command line arguments os.Args[]. In this I will try and create a sample banner program that shall Take 3 arguments n - Number of times a message has to be repeated. m - The message that needs to be shown. d - If debug message needs to be shown. I am going to use the flags package.
GoLang: Command line arguments

GoLang: Command line arguments

·1 min
Reading the golang official documentation is fun, today I saw the Variables in package os var Args []string It allows you to hold command line arguments and a simple main program that can help you validate this.
Files: GoLang

Files: GoLang

·2 mins
In the last blog, I tried reading a file in GoLang. My repository in GitHub has all the code that I write (link) Now, I will extend the same program to write to the same file.
Files: GoLang

Files: GoLang

·4 mins
Learning a new syntax and the libraries is always a task, and the only way forward is gradual. In this blog I will try to create a small program to read a text file and will keep updating the program to include more sophistication
GOLang: Reflection

GOLang: Reflection

·3 mins
Must Read # https://blog.golang.org/laws-of-reflection https://golang.org/pkg/reflect/ https://golang.org/pkg/reflect/#Kind https://golang.org/pkg/reflect/#Value Package reflect implements run-time reflection, allowing a program to manipulate objects with arbitrary types. Reflection is a way to examine own structure. Let’s try and learn it via examples.
GOLang: Interfaces

GOLang: Interfaces

·3 mins
Interfaces are an interesting concept to learn in GOLANG. There are a tonne of informative articles and here is my contribution to it. In classical Object Oriented everything is treated in parlance of Object or Class like in Java or C++. In Go there is no class or inheritance.