How to trim leading and trailing white spaces a string in Go

1 Answer

0 votes
package main
 
import (
    "fmt"
    "strings"
)
 
func main() {
    s := " \t\n\r go, java \t\n "
     
    s = strings.TrimSpace(s)
     
    fmt.Printf(s)
}
 
 
 
/*
run:
 
go, java
 
*/

 



answered Aug 21, 2020 by avibootz

Related questions

2 answers 223 views
1 answer 125 views
3 answers 145 views
1 answer 217 views
1 answer 186 views
...