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 213 views
1 answer 114 views
3 answers 134 views
1 answer 212 views
1 answer 176 views
...