mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 09:18:59 +00:00
be72dc356c
* Add CentOS parsing and post-processing in fleet * Add tests and amend SyncCPEDatabase * Add test for centosPostProcessing * Changes from PR comments * Amend software test * Fix sync test * Add index to source and vendor * Use os.MkdirTemp * Rearrange migrations * Regenerate test schema * Add support for testing migrations (#4112) * Add support for testing migrations * Rename migration in tests * Changes suggested in PR * Go mod tidy
47 lines
882 B
Go
47 lines
882 B
Go
// Package ptr includes functions for creating pointers from values.
|
|
package ptr
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
// String returns a pointer to the provided string.
|
|
func String(x string) *string {
|
|
return &x
|
|
}
|
|
|
|
// StringValueOrZero returns the string value.
|
|
// Returns empty string if x is nil.
|
|
func StringValueOrZero(x *string) string {
|
|
if x == nil {
|
|
return ""
|
|
}
|
|
return *x
|
|
}
|
|
|
|
// Int returns a pointer to the provided int.
|
|
func Int(x int) *int {
|
|
return &x
|
|
}
|
|
|
|
// Uint returns a pointer to the provided uint.
|
|
func Uint(x uint) *uint {
|
|
return &x
|
|
}
|
|
|
|
// Bool returns a pointer to the provided bool.
|
|
func Bool(x bool) *bool {
|
|
return &x
|
|
}
|
|
|
|
// Time returns a pointer to the provided time.Time.
|
|
func Time(x time.Time) *time.Time {
|
|
return &x
|
|
}
|
|
|
|
// RawMessage returns a pointer to the provided json.RawMessage.
|
|
func RawMessage(x json.RawMessage) *json.RawMessage {
|
|
return &x
|
|
}
|