Integer type policy

Integers are for numbers, enabling arithmetic like subtractions and for
loops without getting shot in the foot. Unsigneds are for bitfields.

- "int" for numbers that will always be laughably smaller than four
  billion, and where we don't care about the serialization format.

- "int32" for numbers that will always be laughably smaller than four
  billion, and will be serialized to four bytes.

- "int64" for numbers that may approach four billion or will be
  serialized to eight bytes.

- "uint32" and "uint64" for bitfields, depending on required number of
  bits and serialization format. Likewise "uint8" and "uint16", although
  rare in this project since they don't exist in XDR.

- "int8", "int16" and plain "uint" are almost never useful.
This commit is contained in:
Jakob Borg
2015-01-18 02:12:06 +01:00
parent 221e3eddd5
commit 2c8b627008
30 changed files with 181 additions and 151 deletions

12
Godeps/Godeps.json generated
View File

@@ -27,7 +27,7 @@
},
{
"ImportPath": "github.com/calmh/xdr",
"Rev": "214788d8fedfc310c18eca9ed12be408a5054cd5"
"Rev": "ff948d7666c5e0fd18d398f6278881724d36a90b"
},
{
"ImportPath": "github.com/juju/ratelimit",
@@ -35,7 +35,7 @@
},
{
"ImportPath": "github.com/syncthing/protocol",
"Rev": "f76b5d800208131015b14cfc1cfd3e6dd1d5e979"
"Rev": "15bf5f583a88b7aaf0a5b810fcf5fb21da0a3b3f"
},
{
"ImportPath": "github.com/syndtr/goleveldb/leveldb",
@@ -59,19 +59,19 @@
},
{
"ImportPath": "golang.org/x/crypto/bcrypt",
"Rev": "731db29863ea7213d9556d0170afb38987f401d4"
"Rev": "4ed45ec682102c643324fae5dff8dab085b6c300"
},
{
"ImportPath": "golang.org/x/crypto/blowfish",
"Rev": "731db29863ea7213d9556d0170afb38987f401d4"
"Rev": "4ed45ec682102c643324fae5dff8dab085b6c300"
},
{
"ImportPath": "golang.org/x/text/transform",
"Rev": "985ee5acfaf1ff6712c7c99438752f8e09416ccb"
"Rev": "c980adc4a823548817b9c47d38c6ca6b7d7d8b6a"
},
{
"ImportPath": "golang.org/x/text/unicode/norm",
"Rev": "985ee5acfaf1ff6712c7c99438752f8e09416ccb"
"Rev": "c980adc4a823548817b9c47d38c6ca6b7d7d8b6a"
}
]
}