How to assign string to bytes array in Go

1 Answer

0 votes
package main 
  
import ( 
    "fmt"
	"encoding/binary"
) 
  
func main() { 
	ba := []byte("go java c c++ php python")
  
    fmt.Printf("%s\n", ba);
    fmt.Printf("%c %c\n", ba[0], ba[binary.Size(ba) - 1]);
}


   
/*
run:
   
go java c c++ php python
g n
  
*/

 



answered Aug 6, 2020 by avibootz

Related questions

1 answer 125 views
1 answer 190 views
190 views asked Aug 6, 2020 by avibootz
1 answer 267 views
1 answer 203 views
...