Welcome To Golang By Example

Menu
  • Home
  • Blog
  • Contact Us
  • Support this website
Menu

Category: Tech

Write multiline string in Go (Golang)

Posted on February 23, 2020February 23, 2020 by admin

A backquote (`) can be used to write a multiline string in Golang. Note that a string encoded in backquotes is a raw literal string and doesn’t honor any kind of escaping….

Remove or Strip all white spaces from a string in Go (Golang)

Posted on February 23, 2020February 23, 2020 by admin

strings.ReplaceAll function can be used to trim all white spaces from a string in Golang. Below is the signature of the function s(first argument) is the input string old(second argument) is the…

Parse a bool or Check if given string is a bool in Go (Golang)

Posted on February 23, 2020February 23, 2020 by admin

strconv.ParseBool() function can be used to parse a string representation of a bool. https://golang.org/pkg/strconv/#ParseBool Below is the signature of the function Let’s see a working code Output:

Parse a string to float in Go (Golang)

Posted on February 23, 2020March 10, 2020 by admin

strconv.ParseFloat() function can be used to parse a string representation of a float https://golang.org/pkg/strconv/#ParseFloat Below is the signature of the function Some points worth noting The first argument is the string representation…

Check if a string is a number in Go (Golang)

Posted on February 23, 2020February 23, 2020 by admin

strconv.Atoi() function can be used to check if the string is a number. If this function returns an error if the passed string is not a number. This function parses the number…

Check if a environment variable is set in Go (Golang)

Posted on February 23, 2020February 23, 2020 by admin

os.LookupEnv function can be used to check whether a particular environment variable is set or not. It returns a bool which is true if the given env variable set otherwise false. Let’s…

Get number of currently running/active goroutines

Posted on February 23, 2020February 23, 2020 by admin

NumGoroutine function of runtime package can be used to know the currently running/active goroutines. https://golang.org/pkg/runtime/#NumGoroutine Below is the signature of the function Working Code: Output:

Move file from one location to another in or command mv in Go (Golang)

Posted on February 22, 2020April 16, 2020 by admin

os.Rename() function can be used to mv or move a file from one location to another. It is equivalent to command ‘mv’ of Linux. Below is the signature of the function Code:

List all env variables in Go

Posted on February 22, 2020March 16, 2020 by admin

Overview os package provides an Environ() function to get the list all environment variables. Get all the env variables. It returns an array of string. There is also a way to clear…

Set or Unset or Get Environment Variables in Golang

Posted on February 22, 2020February 22, 2020 by admin

Overview os package provides a couple of utility methods related to playing around env variables in Go. Setting an env value Get an env value The value returned by the Getenv() function…

Posts pagination

Previous 1 … 50 51 52 … 62 Next
Follow @golangbyexample

Popular Articles

Golang Comprehensive Tutorial Series

All Design Patterns in Go (Golang)

Slice in golang

Variables in Go (Golang) – Complete Guide

OOP: Inheritance in GOLANG complete guide

Using Context Package in GO (Golang) – Complete Guide

All data types in Golang with examples

Understanding time and date in Go (Golang) – Complete Guide

©2025 Welcome To Golang By Example | Design: Newspaperly WordPress Theme