All Go Rust Python PHP JavaScript
Chrome Dev Summit to secure your spot in workshops, office hours and learning lounges!

How to Recover panic in Golang

Defer, Panic, and Recover in Go. panic During a typical panic, normal execution stops, all deferred function calls in that goroutine are executed, and the program crashes with a log message. package main func main() { panic("invalid") } ...
Unused

How to Use Deferred Function Calls in Golang

Understanding defer in Go. Deferred Function Calls A defer statement is an ordinary function or method call prefixed by the keyword defer. The function and argument expressions are evaluated when the statement is executed, but the actual call is def...
ada

How to Execute a Shell Command in Go

In Golang, using the exec.Command() function is the easiest way to execute a shell command Using exec.Command Function Command returns the Cmd struct to execute the named program with the given arguments. You can execute a shell command using the e...
aweis

How to Execute a Program or Call a System Command in Python

In Python, there are 3 ways to execute a program or call a system command. Using subprocess Module The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. See the following e...
Patcher56

How to Check whether a File Exists in Python

In Python, there are 3 ways to check if a file exists. Using os.path.exists Method Return True if path refers to an existing path or an open file descriptor. Returns False for broken symbolic links. On some platforms, this function may return False ...
Patcher56

How many keywords are there in Go

List of Golang Keywords. Keywords The following keywords are reserved and may not be used as identifiers. break default func interface select case defer go map struct chan else goto package switch const ...
Sambhav Khandelwal

How to check if a map contains a key in Go

3 ways to find a key in a map.Use second return value directly in an if statement If "BST" is indeed present in the map, the body of the if statement will be executed and v will be local to that scope. package main import "fmt" func main() { di...
Tomoki

How to use the history command in Linux

history command is used to view the previously executed command. The history command works with the command history list. When the command is issued with no options, it prints the history list. The History library provides a history expansion featur...

How to use the free command in Linux

Display amount of free and used memory in the system. free displays the total amount of free and used physical and swap memory in the system, as well as the buffers and caches used by the kernel. The information is gathered by parsing /proc/meminfo....

How to use the curl command in Linux

command line tool and library for transferring data with URLs. cURL (pronounced 'curl') is a computer software project providing a library (libcurl) and command-line tool (curl) for transferring data using various network protocols. The name ...

How to use the chmod command in Linux

chmod is the command and system call used to change the access permissions of file system objects (files and directories) sometimes known as modes. The chmod command sets the file permissions flags on a file or folder. The flags define who can read,...

How to use the alias command in Linux

Alias command instructs the shell to replace one string with another string while executing the commands. The alias command lets you give your own name to a command or sequence of commands. You can then type your short name, and the shell will execu...

How to use the go mod command line

Go mod provides access to operations on modules. Initialize new module in current directory. If you plan to publish your module for others to use, the module path must be a location from which Go tools can download your module. go mod init ...

How to use the go clean command line

Remove object files and cached files. Clean removes object files from package source directories. The go command builds most objects in a temporary directory, so go clean is mainly concerned with object files left by other tools or by manual invocati...

How to use the go command line

Go is a tool for managing Go source code. Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. Go install. 1. Extract the archive you downloaded into /usr/local, creating a Go tree ...