Golang path/filepath.Match() function example

package path/filepath

Golang path/filepath.Match() function usage example

 package main

 import (
 "fmt"
 "path/filepath"
 )

 func main() {

 pattern := "a*"

 ok, err := filepath.Match(pattern, "apple.mp4")

 if err != nil {
 panic(err)
 }

 if ok {
 fmt.Println("File name matched!")
 } else {
 fmt.Println("File name mis-matched!")
 }
 }

References :

http://golang.org/pkg/path/filepath/#Match

Advertisement