Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Variable-length-quantity/Go/variable-length-quantity.go
Normal file
16
Task/Variable-length-quantity/Go/variable-length-quantity.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"encoding/binary"
|
||||
)
|
||||
|
||||
func main() {
|
||||
buf := make([]byte, binary.MaxVarintLen64)
|
||||
for _, x := range []int64{0x200000, 0x1fffff} {
|
||||
v := buf[:binary.PutVarint(buf, x)]
|
||||
fmt.Printf("%d encodes into %d bytes: %x\n", x, len(v), v)
|
||||
x, _ = binary.Varint(v)
|
||||
fmt.Println(x, "decoded")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue