GoLang – THE CORE PACKAGES (2)

GoLang – THE CORE PACKAGES (2)

SERVERS Writing network servers is very easy in Go. TCP Take a look at how to create a TCP server that is shown below- package main import (  “encoding/gob”  “fmt”  “net” ) func server() {  // listen on a port  ln, err :=...
GoLang – THE CORE PACKAGES (1)

GoLang – THE CORE PACKAGES (1)

Instead of writing everything from scratch, most real-world programming depends on the ability to interface with existing libraries. This section will take a look at some of the most commonly used packages included with Go. First a word of caution: although a few of...
GoLang – PACKAGES

GoLang – PACKAGES

EXPORTED NAMES The functions Area and Diagonal are capitalized in the rectangle package. This has a special meaning in Go. Any variable or function that begins with a capital letter is exported names in go. Just exported functions and variables can be accessed from...
GoLang – PACKAGES (1)

GoLang – PACKAGES (1)

Go was designed to be a language that supports great software engineering practices. An important piece of fantastic software is code reuse – encapsulated in the guideline “Do not Repeat Yourself.” A package is declared with the package keyword. The filename...
GoLang – CHANNELS Contd…

GoLang – CHANNELS Contd…

RANGE And CLOSE To indicate that no more values will be sent, a sender can close the channel. Receivers can test if a channel has been closed by assigning a second parameter to the receive expression: after v, ok := <-ch If there are no more values to receive and...
GoLang – CONCURRENCY (GOROUTINES & CHANNELS)

GoLang – CONCURRENCY (GOROUTINES & CHANNELS)

WaitGroup WaitGroup is a good concept in goroutines that will wait for other goroutines to finish their execution. Occasionally, for executing one activity, other activities need to finish. As WaitGroup waits for a number of Goroutines to finish their execution, the...
WhatsApp chat