Go strings Package HasPrefix()

Introduction

To determine if a bigger string starts with a smaller string, use the HasPrefix function:

package main //from   w  w  w  .  ja  v  a 2 s .co  m

import ( 
    "fmt" 
    "strings" 
) 

func main() { 
    // func HasPrefix(s, prefix string) bool 
    fmt.Println(strings.HasPrefix("test", "te")) 
    // => true 
} 



PreviousNext

Related