Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
3
Task/Variable-size-Get/Go/variable-size-get-1.go
Normal file
3
Task/Variable-size-Get/Go/variable-size-get-1.go
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import "unsafe"
|
||||
|
||||
unsafe.Sizeof(x)
|
||||
25
Task/Variable-size-Get/Go/variable-size-get-2.go
Normal file
25
Task/Variable-size-Get/Go/variable-size-get-2.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// unsafe.Sizeof returns the size in bytes.
|
||||
var i int
|
||||
fmt.Println(unsafe.Sizeof(i))
|
||||
// The size returned is that of the top level object and does not
|
||||
// include any referenced data. A type like string always returns
|
||||
// the same number, the size of the string header.
|
||||
fmt.Println(unsafe.Sizeof("Rosetta"))
|
||||
fmt.Println(unsafe.Sizeof("Code"))
|
||||
// For some untrusted environments, package unsafe is not available
|
||||
// but reflect is. The Size method of a type will return the same value
|
||||
// as unsafe.Sizeof.
|
||||
fmt.Println(reflect.TypeOf("Cod").Size())
|
||||
// Some sizes are implementation dependent.
|
||||
fmt.Println(runtime.Version(), runtime.GOARCH)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue