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

How to Stop a goroutine in Golang

Several Ways to Stop Goroutine in Go. A signal channel Typically, you pass the goroutine a (possibly separate) signal channel. That signal channel is used to push a value into when you want the goroutine to stop. The goroutine polls that channel reg...
pooriabt

How to Remove all Whitespace in a String in Python

In Python, there are 3 ways to remove all whitespace in a string. Using str.replace Function The str.replace(x) function returns a copy of the string with all occurrences of substring old replaced by new. See the following example: #!/usr/bin/p...
pooriabt

How to Do a Case Insensitive Regular Expression in Go

In Golang, using the a case-insensitive flag is the easiest way to do a case insensitive regular expression. Using a case-insensitive flag You can set a case-insensitive flag as the first item in the regex. You can add a (?i) at the beginning of th...
ada

How to Append Text to a File in Go

In Golang, using the os.O_APPEND flag is the easiest way to append text to a file Using os.OpenFile Function OpenFile is the generalized open call; most users will use Open or Create instead. It opens the named file with specified flag (O_RDONLY etc...
ada

How to Split a String in Rust

In Rust, there are 3 ways to split a string. Using split Function An iterator over substrings of this string slice, separated by characters matched by a pattern. See the following example: fn main() { let s = "abc1bcd2e"; let _split = s.sp...
ada

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 to check if string contains a substring in Go

Go test string contains substring.Using strings.Contains Function How do I check if a string is a substring of another string in Go? Use the function Contains from the strings package. Contains function returns a boolean value. It returns true if the...
Tomoki

How to convert interface to int64 in Go

Interface variable conversion in Golang.Type Assertion To convert interface to int64 in Go, Using Type Assertion. A type assertion provides access to an interface value's underlying concrete value. package main import "fmt" // t := i.(T) // t, ok ...
ada

How to use the grep command in Linux

Search for PATTERN in each FILE or standard input. grep is a command-line utility for searching plain-text data sets for lines that match a regular expression. Its name comes from the ed command g/re/p (globally search for a regular expression and p...

How to use the find command in Linux

search for files and directories based on their permissions, type, date, ownership, size, and more. find is a command-line utility that locates files based on some user-specified criteria and either prints the pathname of each matched object or, if ...

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 go doc command line

Show documentation for package or symbol. Doc prints the documentation comments associated with the item identified by its arguments (a package, const, func, type, var, method, or struct field) followed by a one-line summary of each of the first-leve...

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 ...