How to convert a slice of bytes to uppercase in Go

2 Answers

0 votes
package main
 
import (
    "fmt"
    "bytes"
)
 
func main() {
   slice := []byte{'g', 'o', 'l', 'a', 'n', 'g'}
         
   sliceu := bytes.ToUpper(slice) 
 
   fmt.Printf("%s", sliceu) 
}
 
 
 
/*
run:
 
GOLANG
 
*/

 



answered May 24, 2020 by avibootz
0 votes
package main
 
import (
    "fmt"
    "bytes"
)
 
func main() {
   sliceu := bytes.ToUpper([]byte("golang"))
 
   fmt.Printf("%s", sliceu) 
}
 

 
 
/*
run:
 
GOLANG
 
*/

 



answered May 24, 2020 by avibootz

Related questions

1 answer 176 views
1 answer 180 views
2 answers 221 views
1 answer 264 views
2 answers 289 views
2 answers 226 views
...