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

How to Change the Current Directory in Go

In Golang, there are 2 ways to change the current directory. Using Dir Property Usually if you need a command to run from a specific directory, you can specify that as the Dir property on the Command, for example: package main import ( "os/...
Unused

How to Make First Letter of Words Uppercase in a String in Go

In Golang, using the cases package is the easiest way to make first letter of words uppercase in a string. Using cases Package install Use the following command to download the repository to the local file system. install go mod tidy ...
pooriabt

How to Pipe Several Commands in Go

In Golang, there are 2 ways to pipe several commands. Using piped commands For example, this function retrieves the CPU model name using piped commands: package main import ( "fmt" "os/exec" ) func main() { cmd := "cat /proc/cpuinfo | eg...
Patcher56

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 Access Command-Line Arguments in Go

In Golang, there are 2 ways to access command-line arguments passed to a program. Using os.Args Variable You can access the command-line arguments using the os.Args variable. Note that the first value in this slice is the path to the program, and o...
Unused

How to Prettyprint a JSON File in Python

In Python, there are 2 ways to prettyprint a JSON file. Using json module The json module already implements some basic pretty printing in the dump and dumps functions, with the indent parameter that specifies how many spaces to indent by: #!/us...
Patcher56

How to Generate a UUID in Go

In Golang, there are 4 ways to generate a uuid. Using uuid Package install Use the following command to download the repository to the local file system. install go mod tidy go get github.com/google/uuid go install github.com...
Sambhav Khandelwal

How to List all Standard Packages in Go

In Golang, there are 2 ways to list all standard packages. Using packages go install Use the following command to download the repository to the local file system. install go get golang.org/x/tools/go/packages go install golang.or...
aweis

How to Access Command Line Parameters in Rust

In Rust, there are 2 ways to access command line parameters. Using std::env::args Function This function actually returns the arguments that this program was started with. See the following example: use std::env; fn main() { for arg in env::...
Patcher56

How to Get the Directory of the Currently Running File in Go

In Golang, there are 3 ways to get the directory of the currently running file.Using os.Executable Function Executable returns the path name for the executable that started the current process. The easiest way to get the directory of the currently ...
Patcher56

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 Remove Packages Installed with go get in Go

In Golang, there are 3 ways to remove packages installed with go get. Using go mod tidy go mod tidy ensures that the go.mod file matches the source code in the module. It adds any missing module requirements necessary to build the current module’s p...
ada

How To Split a list into equally sized chunks in Python

In Python, there are 3 ways to split a list into equally sized chunks. Using List Comprehension List comprehensions provide a concise way to create lists. The following example: #!/usr/bin/python3 # -*- coding: utf8 -*- # initialize lst = ['a'] *...
Patcher56

How To Install Go in Linux

In Golang, there are 2 ways to install Go in Linux.Download Packages Download packages for Windows 64-bit, macOS, Linux, and more. Go install Linux Remove any previous Go installation by deleting the /usr/local/go folder (if it exists), then extr...
Unused

Hello World in Rust

In Rust, "Hello World!" is the first basic program. Build and Run In our main.rs, add the following code: // main.rs fn main() { println!("Hello,世界,こんにちは,안녕하세요") } Hello,世界,こんにちは,안녕하세요 we can run our application by typing: B...
pooriabt