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 181 views
1 answer 188 views
2 answers 236 views
1 answer 267 views
2 answers 296 views
2 answers 232 views
...