Taggolang

introduction to testing in go

i

Testing is hugely important in all software. Being able to ensure the correctness of your code and ensure that any changes you make don’t end up breaking anything else in different parts of your codebase is hugely important. Well, of course by testing, you can surely use your print() statement and maybe use a debugger. But in this article, we’re going to be using the...

creating web server in golang

c

A web server is server software, or hardware dedicated to running such software, that can satisfy World Wide Web client requests. A web server can, in general, contain one or more websites. A web server processes incoming network requests over HTTP and several other related protocols. The primary function of a web server is to store, process and deliver web pages to clients.[1] The communication...

todo app-v2 in golang with mongodb

t

In our previous article, be build this app. Not the best todo app, but it works. Still it has a problem. Once you stop the program and re run it, all the data stored in it will be lost. So how to solve this? First you might think about storing the values in a .txt file and then read it in the program. Sure its doable. But it needs a lot of parsing, etc. So use a Database. In this article...

A todo cli app in golang

A

So we’re going to build a simple TODO app in go. By this way, I think we can actually practice what we studied so far. package main import "fmt" func main() { } This is our starting code. First lets create an empty array. todos := []string{} now lets add some elements to it todos = append(todos, "wake up") todos = append(todos, "code") todos = append(todos, "sleep") Lets print to make...

packages in golang

p

 A package is nothing but a directory with some code files, which exposes different variables and/or functions from a single point of reference To be honest we used library and its functions many time. Here! look at this program: package main import ( "fmt" ) func main() { var num = [5]int {1, 2, 4, 3, 5} fmt.Println(len(num)) } Here we used len() function from Go’s standard library...

channel in go

c

A channel is a communication object using which goroutines can communicate with each other. Technically, a channel is a data transfer pipe where data can be passed into or read from. It’s more like one goroutine can send data into a channel, while other goroutines can read that data from the same channel. It’ll be clear once I show you a example create a channel var channel chan...

golang basics- things i missed

g

Well sure, I missed many. But I believe you already had the foundation to learn anything new on your own. Its impossible to cover everything. In fact I don’t even know I’ll cover all the good and interesting things in GO But I promise you I’ll cover everything that is fundamental ‘for you to learn anything new’ So these are the random topics that I thought should be...

functions in golang-basics

f

Consider this below program: package main import "fmt" func main() { fmt.Println("--------------x--------------") fmt.Println("--------------x--------------") fmt.Println("hi") fmt.Println("--------------x--------------") fmt.Println("--------------x--------------") } that "------x------" is just for decoration. sure You can print something like this if you want. But the logics is all matters in...

loops in golang

l

We have ‘for’ loops in GO, that can be used in 3 ways. loops for arrays: Suppose lets say I have an array and I want to print the square of the elements in it. package main import "fmt" func main() { arr := []int{1, 2, 3, 4} fmt.Print(arr) } The idea is we will take one element from array at a time. But you might ask how we’ll do that? So here comes the for loop package...

arrays, structures AND POINTERS in golang

a

We previously used something called Integers which look like this var a int = 5 which was super useful. But suppose let’s say you want to store a collection of integer not a single integer. like my mark in this semester -2, -10, 8. Yes by the way you can also store negative numbers in GO. So whatever, how can we store this collection of elements? Here comes array. SYNTAX: var variable_name...

Most common tags