Instead of things like var ErrFoo = errors.New("foo")
or return fmt.Errorf("foo: %d", n)
I would like a shorthand
syntax that allows to define a new error type.
package textproto | |
import ( | |
"net/textproto" | |
"runtime" | |
"sync" | |
) | |
// CanonincalMIMEHeaderKey is like textproto.CanonicalMIMEHeaderKey but it | |
// memoizes results to avoid repeated allocations of the same string. |
package maps | |
type ReadMostlyMap[K comparable, V any] struct { | |
mu sync.Mutex | |
m atomic.Pointer // map[K]V | |
} | |
func map2ptr[K comparable, V any](m map[K]V) unsafe.Pointer { | |
im := any(m) | |
return *(*unsafe.Pointer)(unsafe.Pointer(&im)) |
Verifying that I control the following Nostr public key: npub1j67s9mwffj6ue909esy4ldyhte9xheu5nh2lwed2qycqfdmfjmuq40chpa |
package bulkinsert | |
import ( | |
"context" | |
"database/sql" | |
"errors" | |
"fmt" | |
"strings" | |
) |
package mysql | |
import ( | |
"bytes" | |
"context" | |
"database/sql" | |
"encoding/csv" | |
"errors" | |
"fmt" | |
"io" |
package xsync | |
import "sync" | |
type TryLocker interface { | |
sync.Locker // Lock(); Unlock() | |
TryLock() bool | |
} | |
// LockAndDo will acquire the lock l and execute fn. |
package batchgetter | |
type Getter[I, T any] interface { | |
Get(context.Context, []I) ([]T, error) | |
} | |
type BatchGetter[I, T any] struct { | |
parent Getter[I, T] | |
batchWait time.Duration | |
package main | |
import "fmt" | |
func genOptIface(name string, opt ...string) { | |
if len(opt) == 0 { | |
panic("zero opt types") | |
} | |
if len(opt) > 10 { | |
panic("too many opt types") |
#include <immintrin.h> | |
#include <stdint.h> | |
int getIndexOf(__m512i const *values, int64_t target) | |
{ | |
__m512i valuesSimd = _mm512_loadu_si512(values); | |
__m512i targetSplatted = _mm512_set1_epi64(target); | |
__mmask8 equalMask = _mm512_cmpeq_epi64_mask(valuesSimd, targetSplatted); | |
uint32_t equalMaskInt = _cvtmask8_u32(equalMask); | |
int index = _tzcnt_u32(equalMaskInt); |