Sprint in Go

Posted by GoDoc
Public (Editable by Users)

Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.

Go
Edit
package main

import (
	"fmt"
	"io"
	"os"
)

func main() {
	const name, age = "Kim", 22
	s := fmt.Sprint(name, " is ", age, " years old.\n")

	io.WriteString(os.Stdout, s) // Ignoring error for simplicity.
}