Switch remote deploy to vendored source builds
Move remote deployment to a vendored source bundle built on the target host via Docker so redeploys no longer require local cross-compilation or host Go installation. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1
vendor/github.com/leaanthony/u/.gitignore
generated
vendored
Normal file
1
vendor/github.com/leaanthony/u/.gitignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.idea/
|
||||
21
vendor/github.com/leaanthony/u/LICENSE
generated
vendored
Normal file
21
vendor/github.com/leaanthony/u/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023-Present Lea Anthony
|
||||
|
||||
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.
|
||||
150
vendor/github.com/leaanthony/u/README.md
generated
vendored
Normal file
150
vendor/github.com/leaanthony/u/README.md
generated
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
# u
|
||||
|
||||
u provides a simple way to create variables that are "unset" by default.
|
||||
|
||||
u is dependency free and has 100% test coverage.
|
||||
|
||||
## Why?
|
||||
|
||||
Go's default values are great most of the time, but sometimes you want to know if a value has been set or not. This is especially true when you want to know if a value has been set to its zero value or not.
|
||||
|
||||
For example, let's say you had a preferences struct like this:
|
||||
|
||||
```go
|
||||
type Preferences struct {
|
||||
UseFeatureX bool
|
||||
Threshold int
|
||||
}
|
||||
|
||||
func processPreferences(prefs Preferences) {
|
||||
// Uh oh...we're in a heap of trouble here...
|
||||
thirdPartyLibrary.EnableFeatureX(prefs.UseFeatureX)
|
||||
thirdPartyLibrary.SetThreshold(prefs.Threshold)
|
||||
}
|
||||
|
||||
func main() {
|
||||
var prefs Preferences
|
||||
processPreferences(prefs)
|
||||
}
|
||||
```
|
||||
|
||||
There is no real way to know if `UseFeatureX` or `Threshold` have been set or not.
|
||||
|
||||
Using this library we can *eliminate* this problem:
|
||||
|
||||
```go
|
||||
type Preferences struct {
|
||||
UseFeatureX u.Bool
|
||||
Threshold u.Int
|
||||
}
|
||||
|
||||
func processPreferences(prefs Preferences) {
|
||||
// #winning
|
||||
if prefs.UseFeatureX.IsSet() {
|
||||
thirdPartyLibrary.EnableFeatureX(prefs.UseFeatureX.Get())
|
||||
}
|
||||
if prefs.Threshold.IsSet() {
|
||||
thirdPartyLibrary.SetThreshold(prefs.Threshold.Get())
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
var prefs Preferences
|
||||
processPreferences(prefs)
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Why should any of this matter?
|
||||
|
||||
It matters when you are working with third party libraries or frameworks that have default values that may not be the same as the Zero Go values.
|
||||
Perhaps the default value for a preference is `true` and you only want to set it if an explicit value has been specified.
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```go
|
||||
var myVar u.Int
|
||||
|
||||
// Set the value
|
||||
myVar.Set(10)
|
||||
|
||||
// Get the value
|
||||
fmt.Println(myVar.Get()) // 10
|
||||
|
||||
// Check if the value has been set
|
||||
fmt.Println(myVar.IsSet()) // true
|
||||
|
||||
// Unset the value
|
||||
myVar.Unset()
|
||||
|
||||
// Check if the value has been set
|
||||
fmt.Println(myVar.IsSet()) // false
|
||||
```
|
||||
|
||||
### Structs
|
||||
|
||||
`New` methods are provided for setting values in structs.
|
||||
|
||||
```go
|
||||
type MyStruct struct {
|
||||
MyVar u.Int
|
||||
MyOption u.Bool
|
||||
}
|
||||
|
||||
myStruct := MyStruct{
|
||||
MyVar: u.NewInt(42),
|
||||
MyOption: u.True,
|
||||
}
|
||||
```
|
||||
|
||||
## Why not use pointer values?
|
||||
|
||||
Yes, that's one way you can solve this issue. Personally, I try to avoid having pointer values as it increases the chance of dereferencing errors. It also feels like a hacky approach to the problem which is one missed test away from a runtime error.
|
||||
|
||||
## Supported types
|
||||
|
||||
- `u.Bool`
|
||||
- `u.Int`
|
||||
- `u.Int8`
|
||||
- `u.Int16`
|
||||
- `u.Int32`
|
||||
- `u.Int64`
|
||||
- `u.Uint`
|
||||
- `u.Uint8`
|
||||
- `u.Uint16`
|
||||
- `u.Uint32`
|
||||
- `u.Uint64`
|
||||
- `u.Float32`
|
||||
- `u.Float64`
|
||||
- `u.Complex64`
|
||||
- `u.Complex128`
|
||||
- `u.String`
|
||||
- `u.Byte`
|
||||
- `u.Rune`
|
||||
|
||||
## Values
|
||||
|
||||
- `u.True`
|
||||
- `u.False`
|
||||
|
||||
## Custom types
|
||||
|
||||
Any type can be used with this library by creating a `u.Var` of that type. For example:
|
||||
|
||||
```go
|
||||
|
||||
type MyCustomType struct {
|
||||
value string
|
||||
}
|
||||
|
||||
var myVar u.Var[MyCustomType]
|
||||
|
||||
// Set the value
|
||||
myVar.Set(MyCustomType{value: "hello"})
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
186
vendor/github.com/leaanthony/u/u.go
generated
vendored
Normal file
186
vendor/github.com/leaanthony/u/u.go
generated
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
package u
|
||||
|
||||
// True is a `bool` that is set to true
|
||||
var True = NewBool(true)
|
||||
|
||||
// False is a `bool` that is set to false
|
||||
var False = NewBool(false)
|
||||
|
||||
// Bool is a `bool` that can be unset
|
||||
type Bool = Var[bool]
|
||||
|
||||
// NewBool creates a new Bool with the given value
|
||||
func NewBool(val bool) Bool {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// String is a `string` that can be unset
|
||||
type String = Var[string]
|
||||
|
||||
// NewString creates a new String with the given value
|
||||
func NewString(val string) String {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Float64 is a `float64` that can be unset
|
||||
type Float64 = Var[float64]
|
||||
|
||||
// NewFloat64 creates a new Float64 with the given value
|
||||
func NewFloat64(val float64) Float64 {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Float32 is a `float32` that can be unset
|
||||
type Float32 = Var[float32]
|
||||
|
||||
// NewFloat32 creates a new Float32 with the given value
|
||||
func NewFloat32(val float32) Float32 {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Uint is a `uint` that can be unset
|
||||
type Uint = Var[uint]
|
||||
|
||||
// NewUint creates a new Uint with the given value
|
||||
func NewUint(val uint) Uint {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Uint8 is a `uint8` that can be unset
|
||||
type Uint8 = Var[uint8]
|
||||
|
||||
// NewUint8 creates a new Uint8 with the given value
|
||||
func NewUint8(val uint8) Uint8 {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Uint16 is a `uint16` that can be unset
|
||||
type Uint16 = Var[uint16]
|
||||
|
||||
// NewUint16 creates a new Uint16 with the given value
|
||||
func NewUint16(val uint16) Uint16 {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Uint32 is a `uint32` that can be unset
|
||||
type Uint32 = Var[uint32]
|
||||
|
||||
// NewUint32 creates a new Uint32 with the given value
|
||||
func NewUint32(val uint32) Uint32 {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Uint64 is a `uint64` that can be unset
|
||||
type Uint64 = Var[uint64]
|
||||
|
||||
// NewUint64 creates a new Uint64 with the given value
|
||||
func NewUint64(val uint64) Uint64 {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Byte is a `byte` that can be unset
|
||||
type Byte = Var[byte]
|
||||
|
||||
// NewByte creates a new Byte with the given value
|
||||
func NewByte(val byte) Byte {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Rune is a `rune` that can be unset
|
||||
type Rune = Var[rune]
|
||||
|
||||
// NewRune creates a new Rune with the given value
|
||||
func NewRune(val rune) Rune {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Complex64 is a `complex64` that can be unset
|
||||
type Complex64 = Var[complex64]
|
||||
|
||||
// NewComplex64 creates a new Complex64 with the given value
|
||||
func NewComplex64(val complex64) Complex64 {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Complex128 is a `complex128` that can be unset
|
||||
type Complex128 = Var[complex128]
|
||||
|
||||
// NewComplex128 creates a new Complex128 with the given value
|
||||
func NewComplex128(val complex128) Complex128 {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Int is an `int` that can be unset
|
||||
type Int = Var[int]
|
||||
|
||||
// NewInt creates a new Int with the given value
|
||||
func NewInt(val int) Int {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Int8 is an `int8` that can be unset
|
||||
type Int8 = Var[int8]
|
||||
|
||||
// NewInt8 creates a new Int8 with the given value
|
||||
func NewInt8(val int8) Int8 {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Int16 is an `int16` that can be unset
|
||||
type Int16 = Var[int16]
|
||||
|
||||
// NewInt16 creates a new Int16 with the given value
|
||||
func NewInt16(val int16) Int16 {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Int32 is an `int32` that can be unset
|
||||
type Int32 = Var[int32]
|
||||
|
||||
// NewInt32 creates a new Int32 with the given value
|
||||
func NewInt32(val int32) Int32 {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Int64 is an `int64` that can be unset
|
||||
type Int64 = Var[int64]
|
||||
|
||||
// NewInt64 creates a new Int64 with the given value
|
||||
func NewInt64(val int64) Int64 {
|
||||
return NewVar(val)
|
||||
}
|
||||
|
||||
// Var is a variable that can be set, unset and queried for its state.
|
||||
type Var[T any] struct {
|
||||
val T
|
||||
set bool
|
||||
}
|
||||
|
||||
// Get the value of the variable
|
||||
// Returns the zero value if unset
|
||||
func (v *Var[T]) Get() T {
|
||||
return v.val
|
||||
}
|
||||
|
||||
// Set the value of the variable
|
||||
func (v *Var[T]) Set(val T) {
|
||||
v.val = val
|
||||
v.set = true
|
||||
}
|
||||
|
||||
// IsSet returns true when a value has been set
|
||||
func (v *Var[T]) IsSet() bool {
|
||||
return v.set
|
||||
}
|
||||
|
||||
// Unset resets the value to the zero value and sets the variable to "unset"
|
||||
func (v *Var[T]) Unset() {
|
||||
v.set = false
|
||||
var temp T
|
||||
v.val = temp
|
||||
}
|
||||
|
||||
// NewVar creates a new Var with the given value
|
||||
func NewVar[T any](val T) Var[T] {
|
||||
return Var[T]{val: val, set: true}
|
||||
}
|
||||
Reference in New Issue
Block a user