How to get the size of 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("%d\n", binary.Size(ba));
    fmt.Printf("%c\n", ba[binary.Size(ba) - 1]);
}


   
/*
run:
   
24
n
  
*/

 



answered Aug 6, 2020 by avibootz

Related questions

...