mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-06 22:18:28 +00:00
Conver to regular Go vendor + dep tool
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
language: go
|
||||
sudo: false
|
||||
|
||||
go:
|
||||
- 1.6.4
|
||||
- 1.7.4
|
||||
- tip
|
||||
|
||||
script: go test -v
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Alexey Palazhchenko
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
# pointer [](https://godoc.org/github.com/AlekSi/pointer) [](https://travis-ci.org/AlekSi/pointer)
|
||||
|
||||
Go package pointer provides helpers to get pointers to values of build-in types.
|
||||
|
||||
```
|
||||
go get github.com/AlekSi/pointer
|
||||
```
|
||||
|
||||
API is stable. [Documentation](http://godoc.org/github.com/AlekSi/pointer).
|
||||
|
||||
|
||||
```go
|
||||
package motivationalexample
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/AlekSi/pointer"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultName = "some name"
|
||||
)
|
||||
|
||||
// Stuff contains optional fields.
|
||||
type Stuff struct {
|
||||
Name *string
|
||||
Comment *string
|
||||
Value *int64
|
||||
Time *time.Time
|
||||
}
|
||||
|
||||
// SomeStuff makes some JSON-encoded stuff.
|
||||
func SomeStuff() (data []byte, err error) {
|
||||
return json.Marshal(&Stuff{
|
||||
Name: pointer.ToString(defaultName), // can't say &defaultName
|
||||
Comment: pointer.ToString("not yet"), // can't say &"not yet"
|
||||
Value: pointer.ToInt64(42), // can't say &42 or &int64(42)
|
||||
Time: pointer.ToTime(time.Date(2014, 6, 25, 12, 24, 40, 0, time.UTC)), // can't say &time.Date(…)
|
||||
})
|
||||
}
|
||||
```
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// Package pointer provides helpers to get pointers to values of build-in types.
|
||||
package pointer // import "github.com/AlekSi/pointer"
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func ToBool(b bool) *bool { return &b }
|
||||
func ToByte(b byte) *byte { return &b }
|
||||
func ToComplex128(c complex128) *complex128 { return &c }
|
||||
func ToComplex64(c complex64) *complex64 { return &c }
|
||||
func ToError(e error) *error { return &e }
|
||||
func ToFloat32(f float32) *float32 { return &f }
|
||||
func ToFloat64(f float64) *float64 { return &f }
|
||||
func ToInt(i int) *int { return &i }
|
||||
func ToInt16(i int16) *int16 { return &i }
|
||||
func ToInt32(i int32) *int32 { return &i }
|
||||
func ToInt64(i int64) *int64 { return &i }
|
||||
func ToInt8(i int8) *int8 { return &i }
|
||||
func ToRune(r rune) *rune { return &r }
|
||||
func ToString(s string) *string { return &s }
|
||||
func ToTime(t time.Time) *time.Time { return &t }
|
||||
func ToUint(u uint) *uint { return &u }
|
||||
func ToUint16(u uint16) *uint16 { return &u }
|
||||
func ToUint32(u uint32) *uint32 { return &u }
|
||||
func ToUint64(u uint64) *uint64 { return &u }
|
||||
func ToUint8(u uint8) *uint8 { return &u }
|
||||
func ToUintptr(u uintptr) *uintptr { return &u }
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
package pointer
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestBool(t *testing.T) {
|
||||
var x bool
|
||||
if *ToBool(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestByte(t *testing.T) {
|
||||
var x byte
|
||||
if *ToByte(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestComplex128(t *testing.T) {
|
||||
var x complex128
|
||||
if *ToComplex128(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestComplex64(t *testing.T) {
|
||||
var x complex64
|
||||
if *ToComplex64(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestError(t *testing.T) {
|
||||
var x error
|
||||
if *ToError(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestFloat32(t *testing.T) {
|
||||
var x float32
|
||||
if *ToFloat32(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestFloat64(t *testing.T) {
|
||||
var x float64
|
||||
if *ToFloat64(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestInt(t *testing.T) {
|
||||
var x int
|
||||
if *ToInt(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestInt16(t *testing.T) {
|
||||
var x int16
|
||||
if *ToInt16(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestInt32(t *testing.T) {
|
||||
var x int32
|
||||
if *ToInt32(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestInt64(t *testing.T) {
|
||||
var x int64
|
||||
if *ToInt64(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestInt8(t *testing.T) {
|
||||
var x int8
|
||||
if *ToInt8(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestRune(t *testing.T) {
|
||||
var x rune
|
||||
if *ToRune(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestString(t *testing.T) {
|
||||
var x string
|
||||
if *ToString(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestTime(t *testing.T) {
|
||||
var x time.Time
|
||||
if *ToTime(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestUint(t *testing.T) {
|
||||
var x uint
|
||||
if *ToUint(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestUint16(t *testing.T) {
|
||||
var x uint16
|
||||
if *ToUint16(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestUint32(t *testing.T) {
|
||||
var x uint32
|
||||
if *ToUint32(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestUint64(t *testing.T) {
|
||||
var x uint64
|
||||
if *ToUint64(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestUint8(t *testing.T) {
|
||||
var x uint8
|
||||
if *ToUint8(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestUintptr(t *testing.T) {
|
||||
var x uintptr
|
||||
if *ToUintptr(x) != x {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func Example() {
|
||||
const (
|
||||
defaultName = "some name"
|
||||
)
|
||||
|
||||
// Stuff contains optional fields.
|
||||
type Stuff struct {
|
||||
Name *string
|
||||
Comment *string
|
||||
Value *int64
|
||||
Time *time.Time
|
||||
}
|
||||
|
||||
b, _ := json.Marshal(&Stuff{
|
||||
Name: ToString(defaultName), // can't say &defaultName
|
||||
Comment: ToString("not yet"), // can't say &"not yet"
|
||||
Value: ToInt64(42), // can't say &42 or &int64(42)
|
||||
Time: ToTime(time.Date(2014, 6, 25, 12, 24, 40, 0, time.UTC)), // can't say &time.Date(…)
|
||||
})
|
||||
|
||||
fmt.Printf("%s", b)
|
||||
|
||||
// Output: {"Name":"some name","Comment":"not yet","Value":42,"Time":"2014-06-25T12:24:40Z"}
|
||||
}
|
||||
Reference in New Issue
Block a user