diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-06 10:13:50 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-06 10:13:50 +0800 |
commit | 1b2e3c0cd0ca1bdf4cad031a0132ae6e802c2c95 (patch) | |
tree | fe8641dacb28b8223b989d6385504e153cbd6d64 /forged/internal/bare/varint.go | |
parent | Add the Apache license (diff) | |
download | forge-1b2e3c0cd0ca1bdf4cad031a0132ae6e802c2c95.tar.gz forge-1b2e3c0cd0ca1bdf4cad031a0132ae6e802c2c95.tar.zst forge-1b2e3c0cd0ca1bdf4cad031a0132ae6e802c2c95.zip |
Import BARE
Diffstat (limited to 'forged/internal/bare/varint.go')
-rw-r--r-- | forged/internal/bare/varint.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/forged/internal/bare/varint.go b/forged/internal/bare/varint.go new file mode 100644 index 0000000..a185ac8 --- /dev/null +++ b/forged/internal/bare/varint.go @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright (c) 2025 Drew Devault <https://drewdevault.com> + +package bare + +import ( + "reflect" +) + +// Int is a variable-length encoded signed integer. +type Int int64 + +// Uint is a variable-length encoded unsigned integer. +type Uint uint64 + +var ( + intType = reflect.TypeOf(Int(0)) + uintType = reflect.TypeOf(Uint(0)) +) + +func getIntKind(t reflect.Type) reflect.Kind { + switch t { + case intType: + return reflect.Int + case uintType: + return reflect.Uint + default: + return t.Kind() + } +} |