Example of Sscan vs Sscanf vs Sscanln from FMT Package
Sscan scans the argument string, storing successive space-separated values into successive arguments. Newlines count as space.
Sscanf scans the argument string, storing successive space-separated values into successive arguments as determined by the format.
Sscanln is similar to Sscan, but stops scanning at a newline and after the final item there must be a newline or EOF.
Example
package main
import (
"fmt"
)
func main(){
var X int
var Y int
fmt.Printf("\nIntital X: %d, Y: %d", X, Y)
fmt.Sscan("100\n200", &X, &Y)
fmt.Printf("\nSscan X: %d, Y: %d", X, Y)
fmt.Sscanf("(10, 20)", "(%d, %d)", &X, &Y)
fmt.Printf("\nSscanf X: %d, Y: %d", X, Y)
fmt.Sscanln("50\n50", &X, &Y)
fmt.Printf("\nSscanln X: %d, Y: %d", X, Y)
}
Output
Intital X: 0, Y: 0
Sscan X: 100, Y: 200
Sscanf X: 10, Y: 20
Sscanln X: 50, Y: 20
Most Helpful This Week
Interfaces with similar methods in Go Programming Language
How to remove all line breaks from a string in Golang?
Empty Interface Type in Go Programming Language
Example of Interface with Type Embedding and Method Overriding in GO language
Convert Int data type to Int16 Int32 Int64
Go program to find Forward(A) record of a domain