Posts
What Does a True RESTful API Means?
· β˜• 4 min read
Introduction The way we used to deliver resources to the client in a server-client setup is now drifting away from REST to a more modern delivery mechanism. Two of them are gRPC and GraphQL. While both these solve a different kind of problem, REST is going to stay for a while. It is the simplest to learn at least. You might have seen job descriptions requiring skills like the ability to design RESTful API.

Benchmarking in Go, with Example
· β˜• 3 min read
Introduction From The Zen of Go: If you think it’s slow, first prove it with a benchmark Don’t assume if things are slow. Benchmark it and see if they are really slow. One thing to note here is benchmarking a program is different from profiling a program. Benchmarking is the way we check how fast our algorithm is for a given unit of the program. In benchmarking, we typically see how many iterations can a piece of code can run in a given time.

Top 6 Free Learning Resources I used to Learn Go
· β˜• 4 min read
The internet is filled with Go learning resources. And I am not going to repeat all the links here. I will list only the resources that I went through. I am a self-taught programmer from start. And have limited knowledge of computer science. Which of course is changing day by day. I had a background in Python before getting into Go. So my recommendations will also be aligned with my experience level.

Optional Parameters Using Option Struct
· β˜• 5 min read
Introduction In last post we learned how we can use functional options to pass parameter to our functions. In this post we’ll see an alternative way to do the same thing. I’ll take the same code from the last post to keep things simple. Variadic Functions for Options 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 type Coffee struct { CoffeeBeans bool Sugar bool SteamedMilk bool } func New(opts .

Optional Parameters using Functional Options
· β˜• 5 min read
Introduction In Python you can assign default value to the functions, like so: 1 2 def my_func(posarg, named_arg=True, another_named_arg="Okay") # logic goes here... But in Go you can’t do this: 1 2 3 func myFunc(posarg, named_arg bool = true, another_named_arg string = "Okay") { // logic goes here... } This will throw a syntax error. Try that? In this post, we’ll see how can we overcome this issue the go way, with something called Function Options.

Sending POST Request in Go with a Body
· β˜• 3 min read
Introduction Send a POST request in golang is pretty daunting if you have a post body and you’re coming from a scripting language like JavaScript or Python. Here in Go, schema for JSON needs to be defined beforehand in order to marshal and unmarshal string back and forth to JSON. Simple POST This marshaling/unmarshalling could be an oneliner if your request body is not nested, or is one level deep, or there is not even a body.

Dynamically Insert Version Info From git tag to Your App
· β˜• 5 min read
Introduction Have you ever ran into a situation where you wanted to version your application, but doing git tag and making a separate commit for updating version number was a two-step process? Isn’t that kinda frustrating? You can even miss to update the version number in your code, which happens to be with me a lot. In this post we’ll see how to convert this two-step process into one. Contents:

WebAssembly with Go
· β˜• 6 min read
I will start this post with a quote from webassembly.org: WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable target for compilation of high-level languages like C/C++/Rust, enabling deployment on the web for client and server applications. webassembly.org blockquote p { padding: 15px 15px 0; } That’s a lot of technical jargon. In very simple terms,

Continuous Integration and Deployment to Beanstalk With Docker
· β˜• 4 min read
In a previous post we discovered how can we run commands on each push and check if the test is passing against multiple versions of go. This is a continuation of the same concept. We are going to deploy our code to Elastic Beanstalk, straight from git push. Elastic Beanstalk is nothing but a wrapper around it’s EC2 infrastructure. It is a developer-centric view of deploying an application on AWS. Developers just have to push the code and Beanstalk can take care of Auto Scaling Group, Elastic Load Balancer, databases etc.

Introduction to BoltDB
· β˜• 5 min read
Why use BoltDB Bolt plays pretty well with Go’s concurrency model, we can do multiple reads concurrently. For pro and cons, I will contrast it with similar database SQLite. I have done SQLite when I worked with Xentrix to develop GUI tools for the artists. Pro It is native go. This means you don’t need any database server running, like SQLite. In oppose to Redis and memcached. Cross-compilation One thing I see a lot appearing on the internet about Bolt is it’s an ability to cross-compile.

Unit Testing, Test Coverage and CI with Travis in Go
· β˜• 7 min read
You can’t think of deploying your application to production without testing it. Neither you can manage a large codebase with confidence without it. Let us go through some basics of unit testing in golang. This post is structured in the following manner: unit testing basics in golang (jump) inbuilt code coverage command understanding subtests and helper function (jump) Travis CI integration (jump) running test against multiple version of go Unit Testing in golang Before I start, I must say that do not test code, test the behavior.

Create Lightweight Docker Images With Multi Staged Build
· β˜• 4 min read
Me Before 1 2 3 4 5 6 7 8 9 10 11 12 FROMgolang:alpineWORKDIR/go/src/github.com/santosh/qagineCOPY . .RUN go get -dRUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o app .EXPOSE8080CMD ["./app"] Me building the image. $ docker build -t sntshk/qagine . Sending build context to Docker daemon 259.6kB Step 1/7 : FROM golang:alpine ---> 760fdda71c8f Step 2/7 : WORKDIR /go/src/github.com/santosh/qagine ---> Running in e2cf75dd1655 Removing intermediate container e2cf75dd1655 ---> 8b4955b2e885 Step 3/7 : COPY .

2019 In a Review, Colemak, Code Reviews and More
· β˜• 5 min read
This year was a transition period for me from a career perspective. I was hearing, understanding and practicing stuff like microservices, fault tolerance, cross-site deployment, REST APIs, software deployment system, agile development and attending meetings & training sessions with the people on the other side of the planet πŸ˜… . 3 years back I never thought I would end up being some place like this. That version of me just wanted to be a compositor.