Introduction to Strings in Go.What is a String?
A string is an immutable sequence of bytes. Strings may contain arbitrary data, including bytes with value 0, but usually they contain human-readable text.
Make a main.go file containing the following...
In PHP, using the $_SERVER variable is the easiest way to get the full URL.
Using $_SERVER Variable
$_SERVER is an array containing information such as headers, paths, and script locations.
The following example should cover whatever you are trying...
In Golang, there are 2 ways to escape the html.
Using EscapeString Function
The html.EscapeString() function escapes special characters like "
In Rust, there are 2 ways to convert a str to a &[u8].
Using as_bytes Function
The as_bytes() method converts a string slice to a byte slice. To convert the byte slice back into a string slice, use the from_utf8 function.
See the following example...
In Rust, there are 4 ways to create multiple lines string.Using triple-quotes
A string literal is a sequence of any Unicode characters enclosed within two U+0022 (double-quote) characters, with the exception of U+0022 itself, which must be escaped b...
3 ways to convert int64 to string in Golang.Using strconv.Itoa Function
The code snippet below shows how to convert an int to a string using the Itoa function.
package main
import (
"fmt"
"strconv"
)
func main() {
s := strconv.Itoa(100)
f...
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...
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...
List Files and Directories.The ls command lists files and directories within the file system, and shows detailed information about them. It is a part of the GNU core utilities package which is installed on all Linux distributions.
List all files, in...
A JavaScript date library for parsing, validating, manipulating, and formatting dates.--pname-- was designed to work both in the browser and in Node.js.
All code should work in both of these environments, and all unit tests are run in both of these e...