1
0
Fork 0
forked from forgejo/forgejo

Integrate public as bindata optionally (#293)

* Dropped unused codekit config

* Integrated dynamic and static bindata for public

* Ignore public bindata

* Add a general generate make task

* Integrated flexible public assets into web command

* Updated vendoring, added all missiong govendor deps

* Made the linter happy with the bindata and dynamic code

* Moved public bindata definition to modules directory

* Ignoring the new bindata path now

* Updated to the new public modules import path

* Updated public bindata command and drop the new prefix
This commit is contained in:
Thomas Boerger 2016-11-29 17:26:36 +01:00 committed by Lunny Xiao
parent 4680c349dd
commit b6a95a8cb3
691 changed files with 305318 additions and 1272 deletions

View file

@ -0,0 +1,8 @@
package iohelper
import "io"
type ByteMultiReader interface {
io.ByteReader
io.Reader
}

111
vendor/github.com/pingcap/go-hbase/iohelper/pbbuffer.go generated vendored Normal file
View file

@ -0,0 +1,111 @@
package iohelper
import (
"encoding/binary"
pb "github.com/golang/protobuf/proto"
"github.com/juju/errors"
)
type PbBuffer struct {
b []byte
}
func NewPbBuffer() *PbBuffer {
b := []byte{}
return &PbBuffer{
b: b,
}
}
func (b *PbBuffer) Bytes() []byte {
return b.b
}
func (b *PbBuffer) Write(d []byte) (int, error) {
b.b = append(b.b, d...)
return len(d), nil
}
func (b *PbBuffer) WriteByte(d byte) error {
return binary.Write(b, binary.BigEndian, d)
}
func (b *PbBuffer) WriteString(d string) error {
return binary.Write(b, binary.BigEndian, d)
}
func (b *PbBuffer) WriteInt32(d int32) error {
return binary.Write(b, binary.BigEndian, d)
}
func (b *PbBuffer) WriteInt64(d int64) error {
return binary.Write(b, binary.BigEndian, d)
}
func (b *PbBuffer) WriteFloat32(d float32) error {
return binary.Write(b, binary.BigEndian, d)
}
func (b *PbBuffer) WriteFloat64(d float64) error {
return binary.Write(b, binary.BigEndian, d)
}
func (b *PbBuffer) WritePBMessage(d pb.Message) error {
buf, err := pb.Marshal(d)
if err != nil {
return errors.Trace(err)
}
_, err = b.Write(buf)
return errors.Trace(err)
}
func (b *PbBuffer) WriteDelimitedBuffers(bufs ...*PbBuffer) error {
totalLength := 0
lens := make([][]byte, len(bufs))
for i, v := range bufs {
n := len(v.Bytes())
lenb := pb.EncodeVarint(uint64(n))
totalLength += len(lenb) + n
lens[i] = lenb
}
err := b.WriteInt32(int32(totalLength))
if err != nil {
return errors.Trace(err)
}
for i, v := range bufs {
_, err = b.Write(lens[i])
if err != nil {
return errors.Trace(err)
}
_, err = b.Write(v.Bytes())
if err != nil {
return errors.Trace(err)
}
}
return nil
}
func (b *PbBuffer) PrependSize() error {
size := int32(len(b.b))
newBuf := NewPbBuffer()
err := newBuf.WriteInt32(size)
if err != nil {
return errors.Trace(err)
}
_, err = newBuf.Write(b.b)
if err != nil {
return errors.Trace(err)
}
*b = *newBuf
return nil
}

177
vendor/github.com/pingcap/go-hbase/iohelper/utils.go generated vendored Normal file
View file

@ -0,0 +1,177 @@
package iohelper
import (
"bytes"
"encoding/binary"
"io"
"github.com/juju/errors"
)
var (
cachedItob [][]byte
)
func init() {
cachedItob = make([][]byte, 1024)
for i := 0; i < len(cachedItob); i++ {
var b bytes.Buffer
writeVLong(&b, int64(i))
cachedItob[i] = b.Bytes()
}
}
func itob(i int) ([]byte, error) {
if i >= 0 && i < len(cachedItob) {
return cachedItob[i], nil
}
var b bytes.Buffer
err := binary.Write(&b, binary.BigEndian, i)
if err != nil {
return nil, errors.Trace(err)
}
return b.Bytes(), nil
}
func decodeVIntSize(value byte) int32 {
if int32(value) >= -112 {
return int32(1)
}
if int32(value) < -120 {
return -119 - int32(value)
}
return -111 - int32(value)
}
func isNegativeVInt(value byte) bool {
return int32(value) < -120 || int32(value) >= -112 && int32(value) < 0
}
func readVLong(r io.Reader) (int64, error) {
var firstByte byte
err := binary.Read(r, binary.BigEndian, &firstByte)
if err != nil {
return 0, errors.Trace(err)
}
l := decodeVIntSize(firstByte)
if l == 1 {
return int64(firstByte), nil
}
var (
i int64
idx int32
)
for idx = 0; idx < l-1; idx++ {
var b byte
err = binary.Read(r, binary.BigEndian, &b)
if err != nil {
return 0, errors.Trace(err)
}
i <<= 8
i |= int64(b & 255)
}
if isNegativeVInt(firstByte) {
return ^i, nil
}
return i, nil
}
func writeVLong(w io.Writer, i int64) error {
var err error
if i >= -112 && i <= 127 {
err = binary.Write(w, binary.BigEndian, byte(i))
if err != nil {
return errors.Trace(err)
}
} else {
var l int32 = -112
if i < 0 {
i = ^i
l = -120
}
var tmp int64
for tmp = i; tmp != 0; l-- {
tmp >>= 8
}
err = binary.Write(w, binary.BigEndian, byte(l))
if err != nil {
return errors.Trace(err)
}
if l < -120 {
l = -(l + 120)
} else {
l = -(l + 112)
}
for idx := l; idx != 0; idx-- {
var mask int64
shiftbits := uint((idx - 1) * 8)
mask = int64(255) << shiftbits
err = binary.Write(w, binary.BigEndian, byte((i&mask)>>shiftbits))
if err != nil {
return errors.Trace(err)
}
}
}
return nil
}
func ReadVarBytes(r ByteMultiReader) ([]byte, error) {
sz, err := readVLong(r)
if err != nil {
return nil, errors.Trace(err)
}
b := make([]byte, sz)
_, err = r.Read(b)
if err != nil {
return nil, errors.Trace(err)
}
return b, nil
}
func WriteVarBytes(w io.Writer, b []byte) error {
lenb, err := itob(len(b))
if err != nil {
return errors.Trace(err)
}
_, err = w.Write(lenb)
if err != nil {
return errors.Trace(err)
}
_, err = w.Write(b)
return errors.Trace(err)
}
func ReadInt32(r io.Reader) (int32, error) {
var n int32
err := binary.Read(r, binary.BigEndian, &n)
return n, errors.Trace(err)
}
func ReadN(r io.Reader, n int32) ([]byte, error) {
b := make([]byte, n)
_, err := io.ReadFull(r, b)
return b, errors.Trace(err)
}
func ReadUint64(r io.Reader) (uint64, error) {
var n uint64
err := binary.Read(r, binary.BigEndian, &n)
return n, errors.Trace(err)
}