s := "" str := "hello" if str[:1] != "" { s = str[:1] }
package main import "fmt" func main() { str := "hello" s := str[:1] if len(s) > 0 { fmt.Println(s) } }