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

How to Check String is In Json Format in Go

In Golang, there are 2 ways to check string is in json format. Using Unmarshal Function The following example should cover whatever you are trying to do: package main import ( "encoding/json" "fmt" ) func isJson(s string) bool { var js ...
pooriabt

How to Get File Creation and Modification Dates Times in Python

In Python, there are 3 ways to get file creation and modification dates times. Using os.path Function The os.path.getmtime() function returns the time of last modification of path. The os.path.getctime() function returns the system’s ctime which, o...
Patcher56

How to Unpack Array as Arguments in Go

In Golang, there are 2 ways to unpack array as arguments. Using Variadic Functions Variadic functions can be called with any number of trailing arguments. Here’s a function that will take an arbitrary number of ints as arguments. For example, p...
Unused

How to Pretty-Print Json in Go

In Golang, there are 2 ways to pretty-print json. Using json.MarshalIndent Function MarshalIndent is like Marshal but applies Indent to format the output. Each JSON element in the output will begin on a new line beginning with prefix followed by one...
ada

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 find the type of an object in Go

In Golang, there are three ways to find the type of an object.Using fmt.Sprintf Function You can use fmt.Sprintf function to get a string representation. For example, package main import "fmt" func main() { i := 10 f := 2.0 var m map[s...
Patcher56

How to use hash function in Python

Secure hashes and message digests.Hash algorithms The hashlib module implements a common interface to many different secure hash and message digest algorithms. Included are the FIPS secure hash algorithms SHA1, SHA224, SHA256, SHA384, and SHA512 (def...
Unused

How to convert string to json in Python

Converting Json to string in Python.Decoding JSON To convert string to json in Python, use the json.loads() function. The json.loads() is a built-in Python function that accepts a valid json string and returns a dictionary to access all elements. The...
pooriabt

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 use fmt.Sprintf Function in Go

Format a string without printing in Go.Basics Package fmt implements formatted I/O with functions analogous to C's printf and scanf. The format 'verbs' are derived from C's but are simpler. fmt.Sprintf Sprintf formats according to a format specif...
Sambhav Khandelwal

How to convert string to json in Go

Converting Json to string in Golang.Decoding JSON Into Structs Go offers built-in support for JSON encoding and decoding, including to and from built-in and custom data types. Unmarshal parses the JSON-encoded data and stores the result in the value ...
aweis

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 convert interface to string in Go

Type casting an interface to a string in go.Using fmt.Sprintf Function To convert interface to string in Go, use fmt.Sprintf function. Sprintf formats according to a format specifier and returns the resulting string. package main import "fmt" var ...
pooriabt

How to use the telnet command in Linux

user interface to the TELNET protocol. Telnet is an application protocol used on the Internet or local area network to provide a bidirectional interactive text-oriented communication facility using a virtual terminal connection. User data is interspe...

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