Standard library / strings
strings.Cut()
Splits at the first separator, returning before, after and found. If absent, before is the original input and after is empty. Expected stdout: 'id 7 true\n'.
Formal Syntax & Structure
go syntaxgo
func Cut(s, sep string) (before, after string, found bool)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | string | Input text or sequence. |
| sep | string | Separator or search sequence. |
Return Value
(before, after string, found bool)
Splits at the first separator, returning before, after and found. If absent, before is the original input and after is empty.
Working Example
Example Snippetgo
package main
import ( "fmt" "strings")
func main() { a, b, ok := strings.Cut("id=7", "=") fmt.Println(string(a), string(b), ok)}