Formatting Float Values

We all need to format float numbers before displaying them to users. In Golang we can use the FormatFloat() method in strconv package Here is a brief overview of how to use FormatFloat() func FormatFloat(f float64, fmt byte, prec, bitSize int) string FormatFloat() accepts 4 parameters and returns formatted number as string. The first parameter […]

Continue reading →

Going Async with Channels and go routines

One of the early Feedback received for Social Paster has been that people wanted Login with Facebook functionality. And Heeding the feedback, I have started working on it. Login with Facebook functionality required me to integrate Facebook’s javascript SDK. After user logs in and authenticates the app, I receive a short lived access token and […]

Continue reading →

Sending Emails from Revel App

Sending emails is a very important functionality for any web app. Go provides an inbuilt net/smtp package. Sending emails is straight forward and simple. However, if you are using Revel, it provides a mail package which is an abstraction over the net/smtp package and makes you lazier. Lets explore Revel’s mail package a bit. We […]

Continue reading →

Mocking Functions while Unit Testing

Continuing from the last blog on testing, Here we will see how we can mock call to a function to ensure we test only one function at a time. Consider the following function, (taken from Post a tweet) When writing test case for serveHomePage(), we need to ensure that we do not invoke respond function. […]

Continue reading →

Unit Testing in Golang

Testing your code is as important as writing it in the first place. So, how do you write unit tests in go? Go provides a testing package, for writing automated test cases. In the example here, I have also used testify as an assertion library. Not spending more time let’s get to code. To begin […]

Continue reading →