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

How to Add Two Numbers in Go

An example program using numbers. Integers And Floating Point Numbers Go has several different types to represent numbers. Generally we split numbers into two different kinds: integers and floating-point numbers. Make a main.go file containing the ...
pooriabt

How to Split a String into a List in Python

In Python, using the str.split method is the easiest way to split a string into a list Using split Method The str.split(sep=None, maxsplit=- 1) method returns a list of the words in the string, using sep as the delimiter string. If maxsplit is given...
ada

How to Get the Difference in Hours Between Two Dates in Go

In Golang, there are 2 ways to get the difference in hours between two dates. Using time.Since Function The time.Since() function returns the time elapsed since t. It is shorthand for time.Now().Sub(t). For example, package main import ( "fm...
Unused

How to Reverse a String in Python

In Python, there are 3 ways to reverse a string. Using slicing Slice notation takes the form [start:stop:step]. #!/usr/bin/python3 s = "Hello World" print(s[::-1]) # syntax # a[start:stop] # items start through stop-1 # a[start:] # items...
pooriabt

How to Get the Maximum Value for an Int Type in Go

In Golang, there are 2 ways to get the maximum value for an int type. Using constant values Since integer types use two's complement arithmetic, you can infer the min/max constant values for int and uint. For example, package main import ( "...
Patcher56

How to Concatenate Two Slices in Go

In Golang, there are 2 ways to concatenate two slices.Using append Function The append built-in function appends elements to the end of a slice. You can use append function, it really simple. For example, package main import "fmt" func main(...
aweis

How to Read a File Line-by-Line in Go

In Golang, there are 2 ways to read a file line-by-line. Using bufio.Scanner Function Scanner provides a convenient interface for reading data such as a file of newline-delimited lines of text. The ones that are currently implemented are: packa...
Sambhav Khandelwal

How to generate a random string in Go

Creating Random Strings of a fixed length in Go. Using rand.Int63 Function Int63 returns a non-negative pseudo-random 63-bit integer as an int64 from the default Source. package main import ( "fmt" "math/rand" "time" ) const letters = "a...
ada

How to format byte size as kilobytes, megabytes in Go

Convert File Size to a human friendly format.Get file size in human-readable units like kilobytes (KB), Megabytes (MB) or GigaBytes (GB) SI (Decimal 1 k = 1,000) A metric prefix is a unit prefix that precedes a basic unit of measure to indicate a mul...
Sambhav Khandelwal

How to get content from a url in Go

Reading from a url resource in Go.Fetching a URL Go provides a collection of packages, grouped under net, that make it easy to send and receive information through the Internet. Package http provides HTTP client and server implementations. packag...
Patcher56

How to use the kill command in Linux

terminate a process. kill is a command that is used in several popular operating systems to send signals to running processes. The command kill sends the specified signal to the specified process or process group. If no signal is specified, the TE...

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 install DropzoneJS

DropzoneJS is an open source library that provides drag’n’drop file uploads with image previews.--pname-- is a JavaScript library that turns any HTML element into a dropzone. This means that a user can drag and drop a file onto it, and Dropzone will ...