repo_name stringlengths 2 55 | dataset stringclasses 1 value | owner stringlengths 3 31 | lang stringclasses 10 values | func_name stringlengths 1 104 | code stringlengths 20 96.7k | docstring stringlengths 1 4.92k | url stringlengths 94 241 | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|
weaver | github_2023 | ServiceWeaver | go | logStacks | func logStacks() {
time.Sleep(time.Second) // Hack to wait for goroutines to end
buf := make([]byte, 1<<20)
n := runtime.Stack(buf, true)
fmt.Fprintln(os.Stderr, string(buf[:n]))
} | // logStacks prints the stacks of live goroutines. This functionality
// is disabled by default but can be enabled to find background work that
// is not obeying cancellation. | https://github.com/ServiceWeaver/weaver/blob/656901ccf43e1ffce053e83e573643697680c223/weavertest/init.go#L327-L332 | 656901ccf43e1ffce053e83e573643697680c223 |
s3cme | github_2023 | mchmarny | go | NewColorableStderr | func NewColorableStderr() io.Writer {
return os.Stderr
} | // NewColorableStderr returns new instance of Writer which handles escape sequence for stderr. | https://github.com/mchmarny/s3cme/blob/f540c5d245ff91d37e7b4ebcf558d00fa0ecab81/vendor/github.com/mattn/go-colorable/colorable_others.go#L28-L30 | f540c5d245ff91d37e7b4ebcf558d00fa0ecab81 |
s3cme | github_2023 | mchmarny | go | Pause | func Pause() (err error) {
_, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/mchmarny/s3cme/blob/f540c5d245ff91d37e7b4ebcf558d00fa0ecab81/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go#L393-L399 | f540c5d245ff91d37e7b4ebcf558d00fa0ecab81 |
s3cme | github_2023 | mchmarny | go | pwrite | func pwrite(fd int, p []byte, offset int64) (n int, err error) {
var _p0 *byte
if len(p) > 0 {
_p0 = &p[0]
}
var _p1 int
_p1 = len(p)
r0, er := C.pwrite64(C.int(fd), C.uintptr_t(uintptr(unsafe.Pointer(_p0))), C.size_t(_p1), C.longlong(offset))
n = int(r0)
if r0 == -1 && er != nil {
err = er
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/mchmarny/s3cme/blob/f540c5d245ff91d37e7b4ebcf558d00fa0ecab81/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go#L981-L994 | f540c5d245ff91d37e7b4ebcf558d00fa0ecab81 |
s3cme | github_2023 | mchmarny | go | callfstatat | func callfstatat(dirfd int, _p0 uintptr, stat uintptr, flags int) (r1 uintptr, e1 Errno) {
r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_fstatat)), 4, uintptr(dirfd), _p0, stat, uintptr(flags), 0, 0)
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/mchmarny/s3cme/blob/f540c5d245ff91d37e7b4ebcf558d00fa0ecab81/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go#L814-L817 | f540c5d245ff91d37e7b4ebcf558d00fa0ecab81 |
s3cme | github_2023 | mchmarny | go | calltruncate | func calltruncate(_p0 uintptr, length int64) (r1 uintptr, e1 Errno) {
r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_truncate)), 2, _p0, uintptr(length), 0, 0, 0, 0)
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/mchmarny/s3cme/blob/f540c5d245ff91d37e7b4ebcf558d00fa0ecab81/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go#L961-L964 | f540c5d245ff91d37e7b4ebcf558d00fa0ecab81 |
obsidian-cli | github_2023 | Yakitrak | go | callsetsid | func callsetsid() (r1 uintptr, e1 Errno) {
r1 = uintptr(C.setsid())
e1 = syscall.GetErrno()
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/Yakitrak/obsidian-cli/blob/0215c9cc6fdeb4d4a265bee4331837bdb9c7b7b7/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go#L497-L501 | 0215c9cc6fdeb4d4a265bee4331837bdb9c7b7b7 |
obsidian-cli | github_2023 | Yakitrak | go | Ftruncate | func Ftruncate(fd int, length int64) (err error) {
_, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/Yakitrak/obsidian-cli/blob/0215c9cc6fdeb4d4a265bee4331837bdb9c7b7b7/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go#L989-L995 | 0215c9cc6fdeb4d4a265bee4331837bdb9c7b7b7 |
obsidian-cli | github_2023 | Yakitrak | go | Flock | func Flock(fd int, how int) (err error) {
_, _, e1 := syscall_syscall(libc_flock_trampoline_addr, uintptr(fd), uintptr(how), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | //go:cgo_import_dynamic libc_fchownat fchownat "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/Yakitrak/obsidian-cli/blob/0215c9cc6fdeb4d4a265bee4331837bdb9c7b7b7/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go#L951-L957 | 0215c9cc6fdeb4d4a265bee4331837bdb9c7b7b7 |
obsidian-cli | github_2023 | Yakitrak | go | Mlock | func Mlock(b []byte) (err error) {
var _p0 unsafe.Pointer
if len(b) > 0 {
_p0 = unsafe.Pointer(&b[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/Yakitrak/obsidian-cli/blob/0215c9cc6fdeb4d4a265bee4331837bdb9c7b7b7/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go#L269-L281 | 0215c9cc6fdeb4d4a265bee4331837bdb9c7b7b7 |
openvpn-ui | github_2023 | d3vilh | go | ShowTablesQuery | func (d *dbBaseOracle) ShowTablesQuery() string {
return "SELECT TABLE_NAME FROM USER_TABLES"
} | // ShowTablesQuery show All the tables in database | https://github.com/d3vilh/openvpn-ui/blob/690f84df426c13ad4742b61fd23e52fcdc489aa0/vendor/github.com/beego/beego/v2/client/orm/db_oracle.go#L84-L86 | 690f84df426c13ad4742b61fd23e52fcdc489aa0 |
openvpn-ui | github_2023 | d3vilh | go | lookupUnsafe | func (t *idnaTrie) lookupUnsafe(s []byte) uint16 {
c0 := s[0]
if c0 < 0x80 { // is ASCII
return idnaValues[c0]
}
i := idnaIndex[c0]
if c0 < 0xE0 { // 2-byte UTF-8
return t.lookupValue(uint32(i), s[1])
}
i = idnaIndex[uint32(i)<<6+uint32(s[1])]
if c0 < 0xF0 { // 3-byte UTF-8
return t.lookupValue(uint32(i), s[2])
}
i = idnaIndex[uint32(i)<<6+uint32(s[2])]
if c0 < 0xF8 { // 4-byte UTF-8
return t.lookupValue(uint32(i), s[3])
}
return 0
} | // lookupUnsafe returns the trie value for the first UTF-8 encoding in s.
// s must start with a full and valid UTF-8 encoded rune. | https://github.com/d3vilh/openvpn-ui/blob/690f84df426c13ad4742b61fd23e52fcdc489aa0/vendor/golang.org/x/net/idna/tables15.0.0.go#L602-L620 | 690f84df426c13ad4742b61fd23e52fcdc489aa0 |
openvpn-ui | github_2023 | d3vilh | go | callnrecvmsg | func callnrecvmsg(s int, msg uintptr, flags int) (r1 uintptr, e1 Errno) {
r1 = uintptr(C.nrecvmsg(C.int(s), C.uintptr_t(msg), C.int(flags)))
e1 = syscall.GetErrno()
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/d3vilh/openvpn-ui/blob/690f84df426c13ad4742b61fd23e52fcdc489aa0/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go#L913-L917 | 690f84df426c13ad4742b61fd23e52fcdc489aa0 |
openvpn-ui | github_2023 | d3vilh | go | Getegid | func Getegid() (egid int) {
r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
egid = int(r0)
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/d3vilh/openvpn-ui/blob/690f84df426c13ad4742b61fd23e52fcdc489aa0/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go#L815-L819 | 690f84df426c13ad4742b61fd23e52fcdc489aa0 |
openvpn-ui | github_2023 | d3vilh | go | Fstatat | func Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_FSTATAT64, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/d3vilh/openvpn-ui/blob/690f84df426c13ad4742b61fd23e52fcdc489aa0/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go#L253-L264 | 690f84df426c13ad4742b61fd23e52fcdc489aa0 |
openvpn-ui | github_2023 | d3vilh | go | sendto | func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/d3vilh/openvpn-ui/blob/690f84df426c13ad4742b61fd23e52fcdc489aa0/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go#L481-L493 | 690f84df426c13ad4742b61fd23e52fcdc489aa0 |
openvpn-ui | github_2023 | d3vilh | go | SetLogger | func SetLogger(l Logger) {
internal.LoggerV2Impl = &internal.LoggerWrapper{Logger: l}
} | // SetLogger sets the logger that is used in grpc. Call only from
// init() functions.
//
// Deprecated: use SetLoggerV2. | https://github.com/d3vilh/openvpn-ui/blob/690f84df426c13ad4742b61fd23e52fcdc489aa0/vendor/google.golang.org/grpc/grpclog/logger.go#L32-L34 | 690f84df426c13ad4742b61fd23e52fcdc489aa0 |
openvpn-ui | github_2023 | d3vilh | go | sizeStringPtr | func sizeStringPtr(p pointer, f *coderFieldInfo, opts marshalOptions) (size int) {
v := **p.StringPtr()
return f.tagsize + protowire.SizeBytes(len(v))
} | // sizeStringPtr returns the size of wire encoding a *string pointer as a String.
// It panics if the pointer is nil. | https://github.com/d3vilh/openvpn-ui/blob/690f84df426c13ad4742b61fd23e52fcdc489aa0/vendor/google.golang.org/protobuf/internal/impl/codec_gen.go#L5129-L5132 | 690f84df426c13ad4742b61fd23e52fcdc489aa0 |
katalyst-core | github_2023 | kubewharf | go | newPluginManager | func newPluginManager(conf *katalystconfig.Configuration) (pluginmanager.PluginManager, error) {
// make sure plugin registration directory already exist
err := os.MkdirAll(conf.PluginRegistrationDir, os.FileMode(0o755))
if err != nil {
return nil, fmt.Errorf("initializes plugin registration dir failed: %s", err)
}
return &customizedPluginManager{
enabled: *atomic.NewBool(false),
PluginManager: pluginmanager.NewPluginManager(
conf.PluginRegistrationDir, /* sockDir */
&record.FakeRecorder{},
),
}, nil
} | // newPluginManager initializes the registration logic for extendable plugins.
// all plugin manager added to generic context must use the same socket and
// default checkpoint path, and if some plugin needs to use a different socket path,
// it should create the plugin manager itself. | https://github.com/kubewharf/katalyst-core/blob/cdf8732c6e66119576e697193d4351dced0cddd4/cmd/katalyst-agent/app/agent/context.go#L146-L160 | cdf8732c6e66119576e697193d4351dced0cddd4 |
katalyst-core | github_2023 | kubewharf | go | ResourceName | func (p *StaticPolicy) ResourceName() string {
return string(apiconsts.ResourceNetBandwidth)
} | // ResourceName returns resource names managed by this plugin | https://github.com/kubewharf/katalyst-core/blob/cdf8732c6e66119576e697193d4351dced0cddd4/pkg/agent/qrm-plugins/network/staticpolicy/policy.go#L256-L258 | cdf8732c6e66119576e697193d4351dced0cddd4 |
katalyst-core | github_2023 | kubewharf | go | processNextWorkItem | func (cl *CNRLifecycle) processNextWorkItem() bool {
key, quit := cl.syncQueue.Get()
if quit {
return false
}
defer cl.syncQueue.Done(key)
err := cl.sync(key.(string))
if err == nil {
cl.syncQueue.Forget(key)
return true
}
utilruntime.HandleError(fmt.Errorf("sync %q failed with %v", key, err))
cl.syncQueue.AddRateLimited(key)
return true
} | // processNextWorkItem dequeues items, processes them, and marks them done.
// It enforces that the sync is never invoked concurrently with the same key. | https://github.com/kubewharf/katalyst-core/blob/cdf8732c6e66119576e697193d4351dced0cddd4/pkg/controller/lifecycle/cnr.go#L213-L230 | cdf8732c6e66119576e697193d4351dced0cddd4 |
katalyst-core | github_2023 | kubewharf | go | filterExpiredPodMetrics | func filterExpiredPodMetrics(metrics []apimetrics.PodMetrics) []apimetrics.PodMetrics {
now := time.Now()
return lo.Filter(metrics, func(item apimetrics.PodMetrics, _ int) bool {
return now.Before(item.Timestamp.Time)
})
} | // filterExpiredPodMetrics is used to filter out metrics before the current time from the metric slice. | https://github.com/kubewharf/katalyst-core/blob/cdf8732c6e66119576e697193d4351dced0cddd4/pkg/controller/spd/indicator-plugin/plugins/resource-portrait/util.go#L107-L112 | cdf8732c6e66119576e697193d4351dced0cddd4 |
devpod | github_2023 | loft-sh | go | WithKeyMap | func (i *Input) WithKeyMap(k *KeyMap) Field {
i.keymap = k.Input
i.textinput.KeyMap.AcceptSuggestion = i.keymap.AcceptSuggestion
return i
} | // WithKeyMap sets the keymap on an input field. | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/github.com/charmbracelet/huh/field_input.go#L439-L443 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | literal | func literal(s string) string {
return regexp.QuoteMeta(s)
} | // literal compiles s into a literal regular expression, escaping any regexp
// reserved characters. | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/github.com/containers/image/v5/docker/reference/regexp.go#L121-L123 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | AddWith | func (w *Watcher) AddWith(name string, opts ...addOpt) error {
_ = getOptions(opts...)
w.mu.Lock()
w.userWatches[name] = struct{}{}
w.mu.Unlock()
_, err := w.addWatch(name, noteAllEvents)
return err
} | // AddWith is like [Watcher.Add], but allows adding options. When using Add()
// the defaults described below are used.
//
// Possible options are:
//
// - [WithBufferSize] sets the buffer size for the Windows backend; no-op on
// other platforms. The default is 64K (65536 bytes). | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/github.com/fsnotify/fsnotify/backend_kqueue.go#L314-L322 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | OverloadID | func (zero *evalZeroArity) OverloadID() string {
return zero.overload
} | // OverloadID implements the InterpretableCall interface method. | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/github.com/google/cel-go/interpreter/interpretable.go#L391-L393 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | GetTotalMilestones | func (m *MilestoneStats) GetTotalMilestones() int {
if m == nil || m.TotalMilestones == nil {
return 0
}
return *m.TotalMilestones
} | // GetTotalMilestones returns the TotalMilestones field if it's non-nil, zero value otherwise. | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/github.com/google/go-github/v30/github/github-accessors.go#L6328-L6333 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | decompress1x_main_loop_bmi2 | func decompress1x_main_loop_bmi2(ctx *decompress1xContext) | // decompress4x_main_loop_x86 is an x86 with BMI2 assembler implementation
// of Decompress1X when tablelog > 8.
//
//go:noescape | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/github.com/klauspost/compress/huff0/decompress_amd64.go#L158-L158 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | Hyperlink | func (o *Output) Hyperlink(link, name string) string {
return OSC + "8;;" + link + ST + name + OSC + "8;;" + ST
} | // Hyperlink creates a hyperlink using OSC8. | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/github.com/muesli/termenv/hyperlink.go#L9-L11 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | BeTrueBecause | func BeTrueBecause(format string, args ...any) types.GomegaMatcher {
return &matchers.BeTrueMatcher{Reason: fmt.Sprintf(format, args...)}
} | // BeTrueBecause succeeds if actual is true and displays the provided reason if it is false
// fmt.Sprintf is used to render the reason | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/github.com/onsi/gomega/matchers.go#L71-L73 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | UseConcurrentReads | func UseConcurrentReads(value bool) ClientOption {
return func(c *Client) error {
c.disableConcurrentReads = !value
return nil
}
} | // UseConcurrentReads allows the Client to perform concurrent Reads.
//
// Concurrent reads are generally safe to use and not using them will degrade
// performance, so this option is enabled by default.
//
// When enabled, WriteTo will use Stat/Fstat to get the file size and determines
// how many concurrent workers to use.
// Some "read once" servers will delete the file if they receive a stat call on an
// open file and then the download will fail.
// Disabling concurrent reads you will be able to download files from these servers.
// If concurrent reads are disabled, the UseFstat option is ignored. | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/github.com/pkg/sftp/client.go#L127-L132 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | newValueFunc | func newValueFunc(desc *Desc, valueType ValueType, function func() float64) *valueFunc {
result := &valueFunc{
desc: desc,
valType: valueType,
function: function,
labelPairs: MakeLabelPairs(desc, nil),
}
result.init(result)
return result
} | // newValueFunc returns a newly allocated valueFunc with the given Desc and
// ValueType. The value reported is determined by calling the given function
// from within the Write method. Take into account that metric collection may
// happen concurrently. If that results in concurrent calls to Write, like in
// the case where a valueFunc is directly registered with Prometheus, the
// provided function must be concurrency-safe. | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/github.com/prometheus/client_golang/prometheus/value.go#L79-L88 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | servicePath | func (linux *systemDRecord) servicePath() string {
return "/etc/systemd/system/" + linux.name + ".service"
} | // Standard service path for systemD daemons | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/github.com/takama/daemon/daemon_linux_systemd.go#L24-L26 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | WithInt64Callback | func WithInt64Callback(callback Int64Callback) Int64ObservableOption {
return int64CallbackOpt{callback}
} | // WithInt64Callback adds callback to be called for an instrument. | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/go.opentelemetry.io/otel/metric/asyncint64.go#L256-L258 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | FaaSName | func FaaSName(val string) attribute.KeyValue {
return FaaSNameKey.String(val)
} | // FaaSName returns an attribute KeyValue conforming to the "faas.name"
// semantic conventions. It represents the name of the single function that
// this runtime instance executes. | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/resource.go#L882-L884 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | EnduserRole | func EnduserRole(val string) attribute.KeyValue {
return EnduserRoleKey.String(val)
} | // EnduserRole returns an attribute KeyValue conforming to the
// "enduser.role" semantic conventions. It represents the actual/assumed role
// the client is making the request under extracted from token or application
// security context. | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/trace.go#L1302-L1304 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | Verify | func Verify(mac *[16]byte, m []byte, key *[32]byte) bool {
var tmp [16]byte
Sum(&tmp, m, key)
return subtle.ConstantTimeCompare(tmp[:], mac[:]) == 1
} | // Verify returns true if mac is a valid authenticator for m with the given key. | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/golang.org/x/crypto/internal/poly1305/poly1305.go#L35-L39 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | Setdomainname | func Setdomainname(p []byte) (err error) {
var _p0 *byte
if len(p) > 0 {
_p0 = &p[0]
}
_, e1 := callsetdomainname(uintptr(unsafe.Pointer(_p0)), len(p))
if e1 != 0 {
err = errnoErr(e1)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go#L569-L579 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | Dup2 | func Dup2(from int, to int) (err error) {
_, _, e1 := syscall_syscall(libc_dup2_trampoline_addr, uintptr(from), uintptr(to), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | //go:cgo_import_dynamic libc_dup dup "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go#L799-L805 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | Creat | func Creat(path string, mode uint32) (fd int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
runtime.EnterSyscall()
r0, e2, e1 := CallLeFuncWithErr(GetZosLibVec()+SYS___CREAT_A<<4, uintptr(unsafe.Pointer(_p0)), uintptr(mode))
runtime.ExitSyscall()
fd = int(r0)
if int64(r0) == -1 {
err = errnoErr2(e1, e2)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go#L664-L678 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | callsetregid | func callsetregid(rgid int, egid int) (r1 uintptr, e1 Errno) {
r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_setregid)), 2, uintptr(rgid), uintptr(egid), 0, 0, 0, 0)
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go#L919-L922 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | yaml_emitter_emit_scalar | func yaml_emitter_emit_scalar(emitter *yaml_emitter_t, event *yaml_event_t) bool {
if !yaml_emitter_select_scalar_style(emitter, event) {
return false
}
if !yaml_emitter_process_anchor(emitter) {
return false
}
if !yaml_emitter_process_tag(emitter) {
return false
}
if !yaml_emitter_increase_indent(emitter, true, false) {
return false
}
if !yaml_emitter_process_scalar(emitter) {
return false
}
emitter.indent = emitter.indents[len(emitter.indents)-1]
emitter.indents = emitter.indents[:len(emitter.indents)-1]
emitter.state = emitter.states[len(emitter.states)-1]
emitter.states = emitter.states[:len(emitter.states)-1]
return true
} | // Expect SCALAR. | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/gopkg.in/yaml.v2/emitterc.go#L683-L704 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
devpod | github_2023 | loft-sh | go | Convert_apiextensions_CustomResourceDefinitionCondition_To_v1_CustomResourceDefinitionCondition | func Convert_apiextensions_CustomResourceDefinitionCondition_To_v1_CustomResourceDefinitionCondition(in *apiextensions.CustomResourceDefinitionCondition, out *CustomResourceDefinitionCondition, s conversion.Scope) error {
return autoConvert_apiextensions_CustomResourceDefinitionCondition_To_v1_CustomResourceDefinitionCondition(in, out, s)
} | // Convert_apiextensions_CustomResourceDefinitionCondition_To_v1_CustomResourceDefinitionCondition is an autogenerated conversion function. | https://github.com/loft-sh/devpod/blob/0ddf4f2cd7137dd6abaaecbab22943126a37a182/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1/zz_generated.conversion.go#L377-L379 | 0ddf4f2cd7137dd6abaaecbab22943126a37a182 |
opentonapi | github_2023 | tonkeeper | go | NewOptComputeSkipReason | func NewOptComputeSkipReason(v ComputeSkipReason) OptComputeSkipReason {
return OptComputeSkipReason{
Value: v,
Set: true,
}
} | // NewOptComputeSkipReason returns new OptComputeSkipReason with value set to v. | https://github.com/tonkeeper/opentonapi/blob/ff7ba60485b4637dc02d96ffa62e71d6ee69f947/pkg/oas/oas_schemas_gen.go#L11936-L11941 | ff7ba60485b4637dc02d96ffa62e71d6ee69f947 |
mox | github_2023 | mjl- | go | RecordID | func RecordID(ctx context.Context, id int64) (DomainFeedback, error) {
e := DomainFeedback{ID: id}
err := ReportsDB.Get(ctx, &e)
return e, err
} | // RecordID returns the report for the ID. | https://github.com/mjl-/mox/blob/93b627ceab9b90cb3669d0adc5d6dc208181fc7a/dmarcdb/reports.go#L111-L115 | 93b627ceab9b90cb3669d0adc5d6dc208181fc7a |
mox | github_2023 | mjl- | go | count | func (r *elemRef) count() int {
if r.node != nil {
return len(r.node.inodes)
}
return int(r.page.count)
} | // count returns the number of inodes or page elements. | https://github.com/mjl-/mox/blob/93b627ceab9b90cb3669d0adc5d6dc208181fc7a/vendor/go.etcd.io/bbolt/cursor.go#L424-L429 | 93b627ceab9b90cb3669d0adc5d6dc208181fc7a |
mox | github_2023 | mjl- | go | ValidHostHeader | func ValidHostHeader(h string) bool {
// The latest spec is actually this:
//
// http://tools.ietf.org/html/rfc7230#section-5.4
// Host = uri-host [ ":" port ]
//
// Where uri-host is:
// http://tools.ietf.org/html/rfc3986#section-3.2.2
//
// But we're going to be much more lenient for now and just
// search for any byte that's not a valid byte in any of those
// expressions.
for i := 0; i < len(h); i++ {
if !validHostByte[h[i]] {
return false
}
}
return true
} | // ValidHostHeader reports whether h is a valid host header. | https://github.com/mjl-/mox/blob/93b627ceab9b90cb3669d0adc5d6dc208181fc7a/vendor/golang.org/x/net/http/httpguts/httplex.go#L209-L227 | 93b627ceab9b90cb3669d0adc5d6dc208181fc7a |
mox | github_2023 | mjl- | go | KeyctlGetKeyringID | func KeyctlGetKeyringID(id int, create bool) (ringid int, err error) {
createInt := 0
if create {
createInt = 1
}
return KeyctlInt(KEYCTL_GET_KEYRING_ID, id, createInt, 0, 0)
} | // Keyctl commands with special signatures.
// KeyctlGetKeyringID implements the KEYCTL_GET_KEYRING_ID command.
// See the full documentation at:
// http://man7.org/linux/man-pages/man3/keyctl_get_keyring_ID.3.html | https://github.com/mjl-/mox/blob/93b627ceab9b90cb3669d0adc5d6dc208181fc7a/vendor/golang.org/x/sys/unix/syscall_linux.go#L1458-L1464 | 93b627ceab9b90cb3669d0adc5d6dc208181fc7a |
mox | github_2023 | mjl- | go | Kill | func Kill(pid int, sig Signal) (err error) {
r0, er := C.kill(C.int(pid), C.int(sig))
if r0 == -1 && er != nil {
err = er
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/mjl-/mox/blob/93b627ceab9b90cb3669d0adc5d6dc208181fc7a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go#L467-L473 | 93b627ceab9b90cb3669d0adc5d6dc208181fc7a |
mox | github_2023 | mjl- | go | read | func read(fd int, p []byte) (n int, err error) {
var _p0 *byte
if len(p) > 0 {
_p0 = &p[0]
}
r0, e1 := callread(fd, uintptr(unsafe.Pointer(_p0)), len(p))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/mjl-/mox/blob/93b627ceab9b90cb3669d0adc5d6dc208181fc7a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go#L514-L525 | 93b627ceab9b90cb3669d0adc5d6dc208181fc7a |
mox | github_2023 | mjl- | go | socketpair | func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/mjl-/mox/blob/93b627ceab9b90cb3669d0adc5d6dc208181fc7a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go#L435-L441 | 93b627ceab9b90cb3669d0adc5d6dc208181fc7a |
mox | github_2023 | mjl- | go | Mount | func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(fsType)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(dir)
if err != nil {
return
}
_, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | //go:cgo_import_dynamic libc_mknodat mknodat "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/mjl-/mox/blob/93b627ceab9b90cb3669d0adc5d6dc208181fc7a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go#L1496-L1512 | 93b627ceab9b90cb3669d0adc5d6dc208181fc7a |
mox | github_2023 | mjl- | go | Getrtable | func Getrtable() (rtable int, err error) {
r0, _, e1 := syscall_rawSyscall(libc_getrtable_trampoline_addr, 0, 0, 0)
rtable = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | //go:cgo_import_dynamic libc_getrlimit getrlimit "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/mjl-/mox/blob/93b627ceab9b90cb3669d0adc5d6dc208181fc7a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go#L1171-L1178 | 93b627ceab9b90cb3669d0adc5d6dc208181fc7a |
mox | github_2023 | mjl- | go | isTitle | func isTitle(c *context) bool {
ct := c.caseType()
if c.info&hasMappingMask == 0 || ct == cTitle {
return true
}
if c.info&exceptionBit == 0 {
if ct == cLower {
c.err = transform.ErrEndOfSpan
return false
}
return true
}
// Get the exception data.
e := exceptions[c.info>>exceptionShift:]
if nTitle := e[1] & lengthMask; nTitle != noChange {
c.err = transform.ErrEndOfSpan
return false
}
nFirst := (e[1] >> lengthBits) & lengthMask
if ct == cLower && nFirst != noChange {
c.err = transform.ErrEndOfSpan
return false
}
return true
} | // isTitle reports whether the current rune is in title case. | https://github.com/mjl-/mox/blob/93b627ceab9b90cb3669d0adc5d6dc208181fc7a/vendor/golang.org/x/text/cases/context.go#L307-L331 | 93b627ceab9b90cb3669d0adc5d6dc208181fc7a |
mox | github_2023 | mjl- | go | lookupValue | func (t *nfcTrie) lookupValue(n uint32, b byte) uint16 {
switch {
case n < 46:
return uint16(nfcValues[n<<6+uint32(b)])
default:
n -= 46
return uint16(nfcSparse.lookup(n, b))
}
} | // lookupValue determines the type of block n and looks up the value for b. | https://github.com/mjl-/mox/blob/93b627ceab9b90cb3669d0adc5d6dc208181fc7a/vendor/golang.org/x/text/unicode/norm/tables15.0.0.go#L2956-L2964 | 93b627ceab9b90cb3669d0adc5d6dc208181fc7a |
asyncapi-codegen | github_2023 | lerenn | go | brokerMessageToV2Issue49ChatSubscribeMessage | func brokerMessageToV2Issue49ChatSubscribeMessage(bMsg extensions.BrokerMessage) (V2Issue49ChatSubscribeMessage, error) {
var msg V2Issue49ChatSubscribeMessage
// Convert to string
payload := string(bMsg.Payload)
msg.Payload = payload // No need for type conversion to reference
// TODO: run checks on msg type
return msg, nil
} | // brokerMessageToV2Issue49ChatSubscribeMessage will fill a new V2Issue49ChatSubscribeMessage with data from generic broker message | https://github.com/lerenn/asyncapi-codegen/blob/e9a7410f9c1bdead862612402fbb5c465e077f3b/test/v2/issues/49/asyncapi.gen.go#L799-L809 | e9a7410f9c1bdead862612402fbb5c465e077f3b |
gonb | github_2023 | janpfeifer | go | CodePath | func (s *State) CodePath() string {
name := MainGo
if s.CellIsTest {
name = MainTestGo
}
return path.Join(s.TempDir, name)
} | // CodePath is the path to where the code is going to be saved. Either `main.go` or `main_test.go` file. | https://github.com/janpfeifer/gonb/blob/f52815182d2d551ef2647d8f53b71ee6e4e106bf/internal/goexec/execcode.go#L163-L169 | f52815182d2d551ef2647d8f53b71ee6e4e106bf |
gonb | github_2023 | janpfeifer | go | DeclareVariable | func DeclareVariable(decls *Declarations, name, value string) {
decls.Variables[name] = &Variable{
Cursor: NoCursor,
CellLines: CellLines{},
Key: name,
Name: name,
ValueDefinition: value,
}
} | // DeclareVariable creates a variable definition in `decls`.
// `value` is copied verbatim, so any type of variable goes. | https://github.com/janpfeifer/gonb/blob/f52815182d2d551ef2647d8f53b71ee6e4e106bf/internal/goexec/wasm.go#L215-L223 | f52815182d2d551ef2647d8f53b71ee6e4e106bf |
walrus | github_2023 | seal-io | go | ExecE | func (wscb *WorkflowStepCreateBulk) ExecE(ctx context.Context, cbs ...func(ctx context.Context, mc ClientSet, created *WorkflowStep) error) error {
_, err := wscb.SaveE(ctx, cbs...)
return err
} | // ExecE calls the given function after executed the query,
// which is always good for cascading create operations. | https://github.com/seal-io/walrus/blob/5aef1b7525ec717b197bdd1a2ea84ff10d10cf33/pkg/dao/model/workflowstep_create.go#L757-L760 | 5aef1b7525ec717b197bdd1a2ea84ff10d10cf33 |
walrus | github_2023 | seal-io | go | Scan | func (wss *WorkflowStageSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, wss.ctx, "Select")
if err := wss.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*WorkflowStageQuery, *WorkflowStageSelect](ctx, wss.WorkflowStageQuery, wss, wss.inters, v)
} | // Scan applies the selector query and scans the result into the given value. | https://github.com/seal-io/walrus/blob/5aef1b7525ec717b197bdd1a2ea84ff10d10cf33/pkg/dao/model/workflowstage_query.go#L803-L809 | 5aef1b7525ec717b197bdd1a2ea84ff10d10cf33 |
walrus | github_2023 | seal-io | go | NameLT | func NameLT(v string) predicate.ResourceDefinitionMatchingRule {
return predicate.ResourceDefinitionMatchingRule(sql.FieldLT(FieldName, v))
} | // NameLT applies the LT predicate on the "name" field. | https://github.com/seal-io/walrus/blob/5aef1b7525ec717b197bdd1a2ea84ff10d10cf33/pkg/dao/model/resourcedefinitionmatchingrule/where.go#L311-L313 | 5aef1b7525ec717b197bdd1a2ea84ff10d10cf33 |
walrus | github_2023 | seal-io | go | ProjectIDIn | func ProjectIDIn(vs ...object.ID) predicate.ResourceRun {
return predicate.ResourceRun(sql.FieldIn(FieldProjectID, vs...))
} | // ProjectIDIn applies the In predicate on the "project_id" field. | https://github.com/seal-io/walrus/blob/5aef1b7525ec717b197bdd1a2ea84ff10d10cf33/pkg/dao/model/resourcerun/where.go#L217-L219 | 5aef1b7525ec717b197bdd1a2ea84ff10d10cf33 |
walrus | github_2023 | seal-io | go | TemplateIDNotIn | func TemplateIDNotIn(vs ...object.ID) predicate.ResourceRun {
return predicate.ResourceRun(sql.FieldNotIn(FieldTemplateID, vs...))
} | // TemplateIDNotIn applies the NotIn predicate on the "template_id" field. | https://github.com/seal-io/walrus/blob/5aef1b7525ec717b197bdd1a2ea84ff10d10cf33/pkg/dao/model/resourcerun/where.go#L562-L564 | 5aef1b7525ec717b197bdd1a2ea84ff10d10cf33 |
walrus | github_2023 | seal-io | go | CreatedByNEQ | func CreatedByNEQ(v string) predicate.ResourceRun {
return predicate.ResourceRun(sql.FieldNEQ(FieldCreatedBy, v))
} | // CreatedByNEQ applies the NEQ predicate on the "created_by" field. | https://github.com/seal-io/walrus/blob/5aef1b7525ec717b197bdd1a2ea84ff10d10cf33/pkg/dao/model/resourcerun/where.go#L1092-L1094 | 5aef1b7525ec717b197bdd1a2ea84ff10d10cf33 |
walrus | github_2023 | seal-io | go | TypeContainsFold | func TypeContainsFold(v string) predicate.WorkflowStep {
return predicate.WorkflowStep(sql.FieldContainsFold(FieldType, v))
} | // TypeContainsFold applies the ContainsFold predicate on the "type" field. | https://github.com/seal-io/walrus/blob/5aef1b7525ec717b197bdd1a2ea84ff10d10cf33/pkg/dao/model/workflowstep/where.go#L415-L417 | 5aef1b7525ec717b197bdd1a2ea84ff10d10cf33 |
walrus | github_2023 | seal-io | go | ValidateWith | func (i Values) ValidateWith(schema *openapi3.Schema) error {
if schema == nil {
return nil
}
// Check required and undefined.
l := sets.StringKeySet(i)
r := sets.NewString(schema.Required...)
a := sets.StringKeySet(schema.Properties)
if diff := r.Difference(l).UnsortedList(); len(diff) != 0 {
return fmt.Errorf("not found required values %v", diff)
}
if diff := l.Difference(a).UnsortedList(); len(diff) != 0 {
return fmt.Errorf("found undefiend values %v", diff)
}
// Validate.
for n, v := range i {
if schema.Properties[n] == nil || schema.Properties[n].Value == nil {
continue
}
var (
s = schema.Properties[n].Value
errTypeFunc = func(name string, ok bool, err error, expectedType string, actualValue any) error {
if !ok {
return fmt.Errorf("%s is not type %s, actual value: %v", name, expectedType, actualValue)
}
if err != nil {
return fmt.Errorf("failed to convert %s to %s: %w", name, expectedType, err)
}
return nil
}
validateSchemaFunc = func(name string, val any) error {
err := s.VisitJSON(val)
if err != nil {
var e *openapi3.SchemaError
if errors.As(err, &e) {
return errorx.Errorf("invalid %s: %v", name, e.Reason)
}
return err
}
return nil
}
)
var (
val any
ok bool
err error
)
switch {
default:
_, ok, err := GetAny[any](v)
if !ok || err != nil {
return errTypeFunc(n, ok, err, s.Type, v)
}
continue
case s.Type == openapi3.TypeString:
val, ok, err = GetString(v)
if !ok || err != nil {
return errTypeFunc(n, ok, err, s.Type, v)
}
case s.Type == openapi3.TypeBoolean:
val, ok, err = GetBool(v)
if !ok || err != nil {
return errTypeFunc(n, ok, err, s.Type, v)
}
case s.Type == openapi3.TypeInteger:
val, ok, err = GetInt(v)
if !ok || err != nil {
return errTypeFunc(n, ok, err, s.Type, v)
}
case s.Type == openapi3.TypeNumber:
val, ok, err = GetNumber(v)
if !ok || err != nil {
return errTypeFunc(n, ok, err, s.Type, v)
}
case HasAnyTypes(s):
// Skip validate for any type.
continue
case s.Type == openapi3.TypeArray:
val, ok, err = GetSlice[any](v)
if !ok || err != nil {
return errTypeFunc(n, ok, err, s.Type, v)
}
case s.Type == openapi3.TypeObject:
val, ok, err = GetMap[any](v)
if !ok || err != nil {
return errTypeFunc(n, ok, err, s.Type, v)
}
}
err = validateSchemaFunc(n, val)
if err != nil {
return err
}
}
return nil
} | // ValidateWith validates the property value with the given schemas. | https://github.com/seal-io/walrus/blob/5aef1b7525ec717b197bdd1a2ea84ff10d10cf33/pkg/dao/types/property/field.go#L43-L148 | 5aef1b7525ec717b197bdd1a2ea84ff10d10cf33 |
scql | github_2023 | secretflow | go | NewBinaryLiteralFromUint | func NewBinaryLiteralFromUint(value uint64, byteSize int) BinaryLiteral {
if byteSize != -1 && (byteSize < 1 || byteSize > 8) {
panic("Invalid byteSize")
}
buf := make([]byte, 8)
binary.BigEndian.PutUint64(buf, value)
if byteSize == -1 {
buf = trimLeadingZeroBytes(buf)
} else {
buf = buf[8-byteSize:]
}
return buf
} | // NewBinaryLiteralFromUint creates a new BinaryLiteral instance by the given uint value in BitEndian.
// byteSize will be used as the length of the new BinaryLiteral, with leading bytes filled to zero.
// If byteSize is -1, the leading zeros in new BinaryLiteral will be trimmed. | https://github.com/secretflow/scql/blob/8ed4e6acc212b9d29b90d5dcdc91216e71424a08/pkg/types/binary_literal.go#L58-L70 | 8ed4e6acc212b9d29b90d5dcdc91216e71424a08 |
scql | github_2023 | secretflow | go | ParseDatetimeFromNum | func ParseDatetimeFromNum(sc *stmtctx.StatementContext, num int64) (Time, error) {
return ParseTimeFromNum(sc, num, mysql.TypeDatetime, DefaultFsp)
} | // ParseDatetimeFromNum is a helper function wrapping ParseTimeFromNum with datetime type and default fsp. | https://github.com/secretflow/scql/blob/8ed4e6acc212b9d29b90d5dcdc91216e71424a08/pkg/types/time.go#L1536-L1538 | 8ed4e6acc212b9d29b90d5dcdc91216e71424a08 |
marvin | github_2023 | undistro | go | MatchesPodSpec | func MatchesPodSpec(rules []types.ResourceRule) bool {
for _, r := range rules {
gr := r.ToGVR().GroupResource()
if defaultPodSpecResources[gr] {
return true
}
}
return false
} | // MatchesPodSpec returns true if any rule matches a Pod spec | https://github.com/undistro/marvin/blob/9cf36105c76fb8b8548d352c031cd47e11ea8aff/pkg/validator/podspec.go#L32-L40 | 9cf36105c76fb8b8548d352c031cd47e11ea8aff |
langchaingo | github_2023 | tmc | go | WithVectorDimensions | func WithVectorDimensions(size int) Option {
return func(p *Store) {
p.vectorDimensions = size
}
} | // WithVectorDimensions is an option for specifying the vector size. | https://github.com/tmc/langchaingo/blob/0672790bb23a2c7e546a4a7aeffc9bef5bbd8c0b/vectorstores/pgvector/options.go#L83-L87 | 0672790bb23a2c7e546a4a7aeffc9bef5bbd8c0b |
beyla | github_2023 | grafana | go | MappedBits | func MappedBits[T comparable](values []T, maps map[T]Bits, opts ...BuilderOpt[T]) Bits {
bo := builderOpts[T]{}
for _, opt := range opts {
opt(&bo)
}
b := Bits(0)
for _, value := range values {
for _, t := range bo.transform {
value = t(value)
}
if val, ok := maps[value]; ok {
b |= val
}
}
return b
} | // MappedBits builds a Bits map from a set of values (e.g. strings) that are mapped in the form
// value --> corresponding Bits value
// in the "maps" constructor argument | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/pkg/internal/helpers/maps/bits.go#L24-L40 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | MarshalText | func MarshalText(w io.Writer, m Message) error { return defaultTextMarshaler.Marshal(w, m) } | // MarshalText writes the proto text format of m to w. | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/test/integration/components/old_grpc/backend/vendor/github.com/golang/protobuf/proto/text_encode.go#L97-L97 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | xorInGeneric | func xorInGeneric(d *state, buf []byte) {
n := len(buf) / 8
for i := 0; i < n; i++ {
a := binary.LittleEndian.Uint64(buf)
d.a[i] ^= a
buf = buf[8:]
}
} | // xorInGeneric xors the bytes in buf into the state; it
// makes no non-portable assumptions about memory layout
// or alignment. | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/test/integration/components/old_grpc/backend/vendor/golang.org/x/crypto/sha3/xor_generic.go#L12-L20 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | Symlink | func Symlink(path string, link string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(link)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/test/integration/components/old_grpc/backend/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go#L1681-L1697 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | Time | func Time(t *Time_t) (tt Time_t, err error) {
r0, _, e1 := RawSyscall(SYS_TIME, uintptr(unsafe.Pointer(t)), 0, 0)
tt = Time_t(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/test/integration/components/old_grpc/backend/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go#L565-L572 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | socket | func socket(domain int, typ int, proto int) (fd int, err error) {
r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/test/integration/components/old_grpc/backend/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go#L81-L88 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | munmap | func munmap(addr uintptr, length uintptr) (err error) {
_, _, e1 := syscall_syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/test/integration/components/old_grpc/backend/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go#L250-L256 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | Renameat | func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(oldpath)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(newpath)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/test/integration/components/old_grpc/backend/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go#L247-L263 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | NewClientTLSFromCert | func NewClientTLSFromCert(cp *x509.CertPool, serverNameOverride string) TransportCredentials {
return NewTLS(&tls.Config{ServerName: serverNameOverride, RootCAs: cp})
} | // NewClientTLSFromCert constructs TLS credentials from the provided root
// certificate authority certificate(s) to validate server connections. If
// certificates to establish the identity of the client need to be included in
// the credentials (eg: for mTLS), use NewTLS instead, where a complete
// tls.Config can be specified.
// serverNameOverride is for testing only. If set to a non empty string,
// it will override the virtual host name of authority (e.g. :authority header
// field) in requests. | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/test/integration/components/old_grpc/backend/vendor/google.golang.org/grpc/credentials/tls.go#L156-L158 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | Close | func Close(fd int) (err error) {
_, _, e1 := syscall_syscall(libc_close_trampoline_addr, uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | //go:cgo_import_dynamic libc_clock_gettime clock_gettime "libc.so"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/test/integration/components/old_grpc/worker/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go#L721-L727 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | Swap | func (l *HandlerList) Swap(name string, replace NamedHandler) bool {
var swapped bool
for i := 0; i < len(l.list); i++ {
if l.list[i].Name == name {
l.list[i] = replace
swapped = true
}
}
return swapped
} | // Swap will swap out all handlers matching the name passed in. The matched
// handlers will be swapped in. True is returned if the handlers were swapped. | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/github.com/aws/aws-sdk-go/aws/request/handlers.go#L234-L245 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | mapassign_faststr | func mapassign_faststr(t *rt.GoType, h unsafe.Pointer, s string) unsafe.Pointer | //go:linkname mapassign_faststr runtime.mapassign_faststr
//goland:noinspection GoUnusedParameter | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/github.com/bytedance/sonic/internal/decoder/stubs_go120.go#L101-L101 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | AddHeader | func (r Response) AddHeader(header string, value string) Response {
r.Header().Add(header, value)
return r
} | // AddHeader is a shortcut for .Header().Add(header,value) | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/github.com/emicklei/go-restful/v3/response.go#L71-L74 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | Any | func (group *RouterGroup) Any(relativePath string, handlers ...HandlerFunc) IRoutes {
for _, method := range anyMethods {
group.handle(method, relativePath, handlers)
}
return group.returnObj()
} | // Any registers a route that matches all the HTTP methods.
// GET, POST, PUT, PATCH, HEAD, OPTIONS, DELETE, CONNECT, TRACE. | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/github.com/gin-gonic/gin/routergroup.go#L147-L153 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | Float64Value | func Float64Value(v *float64) float64 {
if v != nil {
return *v
}
return 0
} | // Float64Value returns the value of the float64 pointer passed in or
// 0 if the pointer is nil. | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/github.com/go-openapi/swag/convert_types.go#L621-L626 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | isTIGER128 | func isTIGER128(fl FieldLevel) bool {
return tiger128Regex.MatchString(fl.Field().String())
} | // isTIGER128 is the validation function for validating if the field's value is a valid TIGER128. | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/github.com/go-playground/validator/v10/baked_in.go#L589-L591 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | appendMerge | func appendMerge(target, sub []int) []int {
lt, ls := len(target), len(sub)
out := make([]int, 0, lt+ls)
for x, y := 0, 0; x < lt || y < ls; {
if x >= lt {
out = append(out, sub[y:]...)
break
}
if y >= ls {
out = append(out, target[x:]...)
break
}
xValue := target[x]
yValue := sub[y]
switch {
case xValue == yValue:
out = append(out, xValue)
x++
y++
case xValue < yValue:
out = append(out, xValue)
x++
case yValue < xValue:
out = append(out, yValue)
y++
}
}
target = append(target[:0], out...)
return target
} | // appendMerge merges and sorts given already SORTED and UNIQUE segments. | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/github.com/gobwas/glob/match/match.go#L33-L72 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | cleanupSurroundingIdentical | func cleanupSurroundingIdentical(groups []diffStats, eq func(i, j int) bool) []diffStats {
var ix, iy int // indexes into sequence x and y
for i, ds := range groups {
// Handle equal group.
if ds.NumDiff() == 0 {
ix += ds.NumIdentical
iy += ds.NumIdentical
continue
}
// Handle unequal group.
nx := ds.NumIdentical + ds.NumRemoved + ds.NumModified
ny := ds.NumIdentical + ds.NumInserted + ds.NumModified
var numLeadingIdentical, numTrailingIdentical int
for j := 0; j < nx && j < ny && eq(ix+j, iy+j); j++ {
numLeadingIdentical++
}
for j := 0; j < nx && j < ny && eq(ix+nx-1-j, iy+ny-1-j); j++ {
numTrailingIdentical++
}
if numIdentical := numLeadingIdentical + numTrailingIdentical; numIdentical > 0 {
if numLeadingIdentical > 0 {
// Remove leading identical span from this group and
// insert it into the preceding group.
if i-1 >= 0 {
groups[i-1].NumIdentical += numLeadingIdentical
} else {
// No preceding group exists, so prepend a new group,
// but do so after we finish iterating over all groups.
defer func() {
groups = append([]diffStats{{Name: groups[0].Name, NumIdentical: numLeadingIdentical}}, groups...)
}()
}
// Increment indexes since the preceding group would have handled this.
ix += numLeadingIdentical
iy += numLeadingIdentical
}
if numTrailingIdentical > 0 {
// Remove trailing identical span from this group and
// insert it into the succeeding group.
if i+1 < len(groups) {
groups[i+1].NumIdentical += numTrailingIdentical
} else {
// No succeeding group exists, so append a new group,
// but do so after we finish iterating over all groups.
defer func() {
groups = append(groups, diffStats{Name: groups[len(groups)-1].Name, NumIdentical: numTrailingIdentical})
}()
}
// Do not increment indexes since the succeeding group will handle this.
}
// Update this group since some identical elements were removed.
nx -= numIdentical
ny -= numIdentical
groups[i] = diffStats{Name: ds.Name, NumRemoved: nx, NumInserted: ny}
}
ix += nx
iy += ny
}
return groups
} | // cleanupSurroundingIdentical scans through all unequal groups, and
// moves any leading sequence of equal elements to the preceding equal group and
// moves and trailing sequence of equal elements to the succeeding equal group.
//
// This is necessary since coalesceInterveningIdentical may coalesce edit groups
// together such that leading/trailing spans of equal elements becomes possible.
// Note that this can occur even with an optimal diffing algorithm.
//
// Example:
//
// Input: [
// {NumIdentical: 61},
// {NumIdentical: 1 , NumRemoved: 11, NumInserted: 2}, // assume 3 leading identical elements
// {NumIdentical: 67},
// {NumIdentical: 7, NumRemoved: 12, NumInserted: 3}, // assume 10 trailing identical elements
// {NumIdentical: 54},
// ]
// Output: [
// {NumIdentical: 64}, // incremented by 3
// {NumRemoved: 9},
// {NumIdentical: 67},
// {NumRemoved: 9},
// {NumIdentical: 64}, // incremented by 10
// ] | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/github.com/google/go-cmp/cmp/report_slices.go#L553-L614 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | Setns | func Setns(ns NsHandle, nstype int) (err error) {
return ErrNotImplemented
} | // Setns sets namespace using golang.org/x/sys/unix.Setns on Linux. It
// is not implemented on other platforms.
//
// Deprecated: Use golang.org/x/sys/unix.Setns instead. | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/github.com/vishvananda/netns/netns_others.go#L18-L20 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | MessagingServicebusMessageEnqueuedTime | func MessagingServicebusMessageEnqueuedTime(val int) attribute.KeyValue {
return MessagingServicebusMessageEnqueuedTimeKey.Int(val)
} | // MessagingServicebusMessageEnqueuedTime returns an attribute KeyValue
// conforming to the "messaging.servicebus.message.enqueued_time" semantic
// conventions. It represents the UTC epoch seconds at which the message has
// been accepted and stored in the entity. | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/go.opentelemetry.io/otel/semconv/v1.25.0/attribute_group.go#L5776-L5778 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | IsValid | func (t TraceID) IsValid() bool {
return !bytes.Equal(t[:], nilTraceID[:])
} | // IsValid checks whether the trace TraceID is valid. A valid trace ID does
// not consist of zeros only. | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/go.opentelemetry.io/otel/trace/trace.go#L43-L45 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | LowercaseLevelEncoder | func LowercaseLevelEncoder(l Level, enc PrimitiveArrayEncoder) {
enc.AppendString(l.String())
} | // LowercaseLevelEncoder serializes a Level to a lowercase string. For example,
// InfoLevel is serialized to "info". | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/go.uber.org/zap/zapcore/encoder.go#L47-L49 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | ToUnicode | func ToUnicode(s string) (string, error) {
return Punycode.process(s, false)
} | // ToUnicode is a wrapper for Punycode.ToUnicode. | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/golang.org/x/net/idna/idna10.0.0.go#L51-L53 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | Setegid | func Setegid(egid int) (err error) {
_, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go#L1542-L1548 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | Seek | func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
newoffset = int64(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go#L1520-L1527 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | sendto | func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
} | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go#L168-L180 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | ForceCodec | func ForceCodec(codec encoding.Codec) CallOption {
return ForceCodecCallOption{Codec: codec}
} | // ForceCodec returns a CallOption that will set codec to be used for all
// request and response messages for a call. The result of calling Name() will
// be used as the content-subtype after converting to lowercase, unless
// CallContentSubtype is also used.
//
// See Content-Type on
// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests for
// more details. Also see the documentation on RegisterCodec and
// CallContentSubtype for more details on the interaction between Codec and
// content-subtype.
//
// This function is provided for advanced users; prefer to use only
// CallContentSubtype to select a registered codec instead.
//
// # Experimental
//
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
// later release. | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/google.golang.org/grpc/rpc_util.go#L498-L500 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | IsValid | func (v Value) IsValid() bool {
return v.typ != nilType
} | // IsValid reports whether v is populated with a value. | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go#L191-L193 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | addKnownTypes | func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&Ingress{},
&IngressList{},
&IngressClass{},
&IngressClassList{},
)
// Add the watch version that applies
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
} | // Adds the list of known types to the given scheme. | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/k8s.io/api/networking/v1beta1/register.go#L48-L58 | 2f2517bd9e5824bcd315292e62102f361a216434 |
beyla | github_2023 | grafana | go | diffMaps | func diffMaps(original, modified map[string]interface{}, schema LookupPatchMeta, diffOptions DiffOptions) (map[string]interface{}, error) {
patch := map[string]interface{}{}
// This will be used to build the $retainKeys directive sent in the patch
retainKeysList := make([]interface{}, 0, len(modified))
// Compare each value in the modified map against the value in the original map
for key, modifiedValue := range modified {
// Get the underlying type for pointers
if diffOptions.BuildRetainKeysDirective && modifiedValue != nil {
retainKeysList = append(retainKeysList, key)
}
originalValue, ok := original[key]
if !ok {
// Key was added, so add to patch
if !diffOptions.IgnoreChangesAndAdditions {
patch[key] = modifiedValue
}
continue
}
// The patch may have a patch directive
// TODO: figure out if we need this. This shouldn't be needed by apply. When would the original map have patch directives in it?
foundDirectiveMarker, err := handleDirectiveMarker(key, originalValue, modifiedValue, patch)
if err != nil {
return nil, err
}
if foundDirectiveMarker {
continue
}
if reflect.TypeOf(originalValue) != reflect.TypeOf(modifiedValue) {
// Types have changed, so add to patch
if !diffOptions.IgnoreChangesAndAdditions {
patch[key] = modifiedValue
}
continue
}
// Types are the same, so compare values
switch originalValueTyped := originalValue.(type) {
case map[string]interface{}:
modifiedValueTyped := modifiedValue.(map[string]interface{})
err = handleMapDiff(key, originalValueTyped, modifiedValueTyped, patch, schema, diffOptions)
case []interface{}:
modifiedValueTyped := modifiedValue.([]interface{})
err = handleSliceDiff(key, originalValueTyped, modifiedValueTyped, patch, schema, diffOptions)
default:
replacePatchFieldIfNotEqual(key, originalValue, modifiedValue, patch, diffOptions)
}
if err != nil {
return nil, err
}
}
updatePatchIfMissing(original, modified, patch, diffOptions)
// Insert the retainKeysList iff there are values present in the retainKeysList and
// either of the following is true:
// - the patch is not empty
// - there are additional field in original that need to be cleared
if len(retainKeysList) > 0 &&
(len(patch) > 0 || hasAdditionalNewField(original, modified)) {
patch[retainKeysDirective] = sortScalars(retainKeysList)
}
return patch, nil
} | // Returns a (recursive) strategic merge patch that yields modified when applied to original.
// Including:
// - Adding fields to the patch present in modified, missing from original
// - Setting fields to the patch present in modified and original with different values
// - Delete fields present in original, missing from modified through
// - IFF map field - set to nil in patch
// - IFF list of maps && merge strategy - use deleteDirective for the elements
// - IFF list of primitives && merge strategy - use parallel deletion list
// - IFF list of maps or primitives with replace strategy (default) - set patch value to the value in modified
// - Build $retainKeys directive for fields with retainKeys patch strategy | https://github.com/grafana/beyla/blob/2f2517bd9e5824bcd315292e62102f361a216434/vendor/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go#L168-L234 | 2f2517bd9e5824bcd315292e62102f361a216434 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.