HasPrefix in Go

Posted by GoDoc
Public (Editable by Users)

HasPrefix tests whether the string s begins with prefix.

Go
Edit
package main

import (
	"fmt"
	"strings"
)

func main() {
	fmt.Println(strings.HasPrefix("Gopher", "Go"))
	fmt.Println(strings.HasPrefix("Gopher", "C"))
	fmt.Println(strings.HasPrefix("Gopher", ""))
}