_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q171200 | yaml_mapping_start_event_initialize | validation | func yaml_mapping_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_mapping_style_t) {
*event = yaml_event_t{
typ: yaml_MAPPING_START_EVENT,
anchor: anchor,
tag: tag,
implicit: implicit,
style: yaml_style_t(style),
}
} | go | {
"resource": ""
} |
q171201 | yaml_emitter_flush | validation | func yaml_emitter_flush(emitter *yaml_emitter_t) bool {
if emitter.write_handler == nil {
panic("write handler not set")
}
// Check if the buffer is empty.
if emitter.buffer_pos == 0 {
return true
}
if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil {
return yaml_emi... | go | {
"resource": ""
} |
q171202 | processConversion | validation | func (c *Checker) processConversion(pkg *lint.Pkg, node ast.Node) {
if node, ok := node.(*ast.CallExpr); ok {
callTyp := pkg.TypesInfo.TypeOf(node.Fun)
var typDst *types.Struct
var ok bool
switch typ := callTyp.(type) {
case *types.Named:
typDst, ok = typ.Underlying().(*types.Struct)
case *types.Pointer... | go | {
"resource": ""
} |
q171203 | processCompositeLiteral | validation | func (c *Checker) processCompositeLiteral(pkg *lint.Pkg, node ast.Node) {
// XXX how does this actually work? wouldn't it match t{}?
if node, ok := node.(*ast.CompositeLit); ok {
typ := pkg.TypesInfo.TypeOf(node)
if _, ok := typ.(*types.Named); ok {
typ = typ.Underlying()
}
if _, ok := typ.(*types.Struct);... | go | {
"resource": ""
} |
q171204 | processCgoExported | validation | func (c *Checker) processCgoExported(pkg *lint.Pkg, node ast.Node) {
if node, ok := node.(*ast.FuncDecl); ok {
if node.Doc == nil {
return
}
for _, cmt := range node.Doc.List {
if !strings.HasPrefix(cmt.Text, "//go:cgo_export_") {
return
}
obj := pkg.TypesInfo.ObjectOf(node.Name)
c.graph.roots... | go | {
"resource": ""
} |
q171205 | WritePackage | validation | func WritePackage(buf *bytes.Buffer, p *Package) {
fmt.Fprintf(buf, "%s:\n", p)
var names []string
maxname := 0
for name := range p.Members {
if l := len(name); l > maxname {
maxname = l
}
names = append(names, name)
}
from := p.Pkg
sort.Strings(names)
for _, name := range names {
switch mem := p.M... | go | {
"resource": ""
} |
q171206 | NewLinter | validation | func NewLinter(name string, config LinterConfig) (*Linter, error) {
if p, ok := predefinedPatterns[config.Pattern]; ok {
config.Pattern = p
}
regex, err := regexp.Compile("(?m:" + config.Pattern + ")")
if err != nil {
return nil, err
}
if config.PartitionStrategy == nil {
config.PartitionStrategy = partitio... | go | {
"resource": ""
} |
q171207 | IsStub | validation | func (d *Descriptions) IsStub(fn *ssa.Function) bool {
if len(fn.Blocks) == 0 {
return true
}
if len(fn.Blocks) > 1 {
return false
}
instrs := lintdsl.FilterDebug(fn.Blocks[0].Instrs)
if len(instrs) != 1 {
return false
}
switch instrs[0].(type) {
case *ssa.Return:
// Since this is the only instruction... | go | {
"resource": ""
} |
q171208 | CheckUnexportedReturn | validation | func (c *Checker) CheckUnexportedReturn(j *lint.Job) {
for _, fn := range j.Program.InitialFunctions {
if fn.Synthetic != "" || fn.Parent() != nil {
continue
}
if !ast.IsExported(fn.Name()) || IsInMain(j, fn) || IsInTest(j, fn) {
continue
}
sig := fn.Type().(*types.Signature)
if sig.Recv() != nil && ... | go | {
"resource": ""
} |
q171209 | CreateProgram | validation | func CreateProgram(lprog *loader.Program, mode ssa.BuilderMode) *ssa.Program {
prog := ssa.NewProgram(lprog.Fset, mode)
for _, info := range lprog.AllPackages {
if info.TransitivelyErrorFree {
prog.CreatePackage(info.Pkg, info.Files, &info.Info, info.Importable)
}
}
return prog
} | go | {
"resource": ""
} |
q171210 | IsIgnored | validation | func (d *directiveParser) IsIgnored(issue *Issue) bool {
d.lock.Lock()
path := issue.Path.Relative()
ranges, ok := d.files[path]
if !ok {
ranges = d.parseFile(path)
sort.Sort(ranges)
d.files[path] = ranges
}
d.lock.Unlock()
for _, r := range ranges {
if r.matches(issue) {
debug("nolint: matched %s to ... | go | {
"resource": ""
} |
q171211 | Unmatched | validation | func (d *directiveParser) Unmatched() map[string]ignoredRanges {
unmatched := map[string]ignoredRanges{}
for path, ranges := range d.files {
for _, ignore := range ranges {
if !ignore.matched {
unmatched[path] = append(unmatched[path], ignore)
}
}
}
return unmatched
} | go | {
"resource": ""
} |
q171212 | LoadFiles | validation | func (d *directiveParser) LoadFiles(paths []string) error {
d.lock.Lock()
defer d.lock.Unlock()
filenames, err := pathsToFileGlobs(paths)
if err != nil {
return err
}
for _, filename := range filenames {
ranges := d.parseFile(filename)
sort.Sort(ranges)
d.files[filename] = ranges
}
return nil
} | go | {
"resource": ""
} |
q171213 | ForArch | validation | func ForArch(arch string) *Sizes {
wordSize := int64(8)
maxAlign := int64(8)
switch build.Default.GOARCH {
case "386", "arm":
wordSize, maxAlign = 4, 4
case "amd64p32":
wordSize = 4
}
return &Sizes{WordSize: wordSize, MaxAlign: maxAlign}
} | go | {
"resource": ""
} |
q171214 | ConvertedFrom | validation | func ConvertedFrom(v Value, typ string) bool {
change, ok := v.Value.(*ssa.ChangeType)
return ok && IsType(change.X.Type(), typ)
} | go | {
"resource": ""
} |
q171215 | yaml_emitter_emit_node | validation | func yaml_emitter_emit_node(emitter *yaml_emitter_t, event *yaml_event_t,
root bool, sequence bool, mapping bool, simple_key bool) bool {
emitter.root_context = root
emitter.sequence_context = sequence
emitter.mapping_context = mapping
emitter.simple_key_context = simple_key
switch event.typ {
case yaml_ALIAS_... | go | {
"resource": ""
} |
q171216 | IsBlank | validation | func IsBlank(id ast.Expr) bool {
ident, _ := id.(*ast.Ident)
return ident != nil && ident.Name == "_"
} | go | {
"resource": ""
} |
q171217 | Dereference | validation | func Dereference(T types.Type) types.Type {
if p, ok := T.Underlying().(*types.Pointer); ok {
return p.Elem()
}
return T
} | go | {
"resource": ""
} |
q171218 | TCPDialCheck | validation | func TCPDialCheck(addr string, timeout time.Duration) Check {
return func() error {
conn, err := net.DialTimeout("tcp", addr, timeout)
if err != nil {
return err
}
return conn.Close()
}
} | go | {
"resource": ""
} |
q171219 | HTTPGetCheck | validation | func HTTPGetCheck(url string, timeout time.Duration) Check {
client := http.Client{
Timeout: timeout,
// never follow redirects
CheckRedirect: func(*http.Request, []*http.Request) error {
return http.ErrUseLastResponse
},
}
return func() error {
resp, err := client.Get(url)
if err != nil {
return e... | go | {
"resource": ""
} |
q171220 | DNSResolveCheck | validation | func DNSResolveCheck(host string, timeout time.Duration) Check {
resolver := net.Resolver{}
return func() error {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
addrs, err := resolver.LookupHost(ctx, host)
if err != nil {
return err
}
if len(addrs) < 1 {
return fmt.... | go | {
"resource": ""
} |
q171221 | NewHandler | validation | func NewHandler() Handler {
h := &basicHandler{
livenessChecks: make(map[string]Check),
readinessChecks: make(map[string]Check),
}
h.Handle("/live", http.HandlerFunc(h.LiveEndpoint))
h.Handle("/ready", http.HandlerFunc(h.ReadyEndpoint))
return h
} | go | {
"resource": ""
} |
q171222 | NewMetricsHandler | validation | func NewMetricsHandler(registry prometheus.Registerer, namespace string) Handler {
return &metricsHandler{
handler: NewHandler(),
registry: registry,
namespace: namespace,
}
} | go | {
"resource": ""
} |
q171223 | Timeout | validation | func Timeout(check Check, timeout time.Duration) Check {
return func() error {
c := make(chan error, 1)
go func() { c <- check() }()
select {
case err := <-c:
return err
case <-time.After(timeout):
return timeoutError(timeout)
}
}
} | go | {
"resource": ""
} |
q171224 | NewPinger | validation | func NewPinger() *Pinger {
rand.Seed(time.Now().UnixNano())
return &Pinger{
id: rand.Intn(0xffff),
seq: rand.Intn(0xffff),
addrs: make(map[string]*net.IPAddr),
network: "ip",
source: "",
source6: "",
hasIPv4: false,
hasIPv6: false,
Size: TimeSliceLength,
MaxRTT: time.Second,
OnRe... | go | {
"resource": ""
} |
q171225 | Network | validation | func (p *Pinger) Network(network string) (string, error) {
origNet := p.network
switch network {
case "ip":
fallthrough
case "udp":
p.network = network
default:
return origNet, errors.New(network + " can't be used as ICMP endpoint")
}
return origNet, nil
} | go | {
"resource": ""
} |
q171226 | AddIP | validation | func (p *Pinger) AddIP(ipaddr string) error {
addr := net.ParseIP(ipaddr)
if addr == nil {
return fmt.Errorf("%s is not a valid textual representation of an IP address", ipaddr)
}
p.mu.Lock()
p.addrs[addr.String()] = &net.IPAddr{IP: addr}
if isIPv4(addr) {
p.hasIPv4 = true
} else if isIPv6(addr) {
p.hasIPv... | go | {
"resource": ""
} |
q171227 | AddIPAddr | validation | func (p *Pinger) AddIPAddr(ip *net.IPAddr) {
p.mu.Lock()
p.addrs[ip.String()] = ip
if isIPv4(ip.IP) {
p.hasIPv4 = true
} else if isIPv6(ip.IP) {
p.hasIPv6 = true
}
p.mu.Unlock()
} | go | {
"resource": ""
} |
q171228 | RemoveIP | validation | func (p *Pinger) RemoveIP(ipaddr string) error {
addr := net.ParseIP(ipaddr)
if addr == nil {
return fmt.Errorf("%s is not a valid textual representation of an IP address", ipaddr)
}
p.mu.Lock()
delete(p.addrs, addr.String())
p.mu.Unlock()
return nil
} | go | {
"resource": ""
} |
q171229 | RemoveIPAddr | validation | func (p *Pinger) RemoveIPAddr(ip *net.IPAddr) {
p.mu.Lock()
delete(p.addrs, ip.String())
p.mu.Unlock()
} | go | {
"resource": ""
} |
q171230 | MakeLang | validation | func MakeLang(s string, lang string) (slug string) {
slug = strings.TrimSpace(s)
// Custom substitutions
// Always substitute runes first
slug = SubstituteRune(slug, CustomRuneSub)
slug = Substitute(slug, CustomSub)
// Process string with selected substitution language
switch lang {
case "de":
slug = Substi... | go | {
"resource": ""
} |
q171231 | Substitute | validation | func Substitute(s string, sub map[string]string) (buf string) {
buf = s
var keys []string
for k := range sub {
keys = append(keys, k)
}
sort.Strings(keys)
for _, key := range keys {
buf = strings.Replace(buf, key, sub[key], -1)
}
return
} | go | {
"resource": ""
} |
q171232 | SubstituteRune | validation | func SubstituteRune(s string, sub map[rune]string) string {
var buf bytes.Buffer
for _, c := range s {
if d, ok := sub[c]; ok {
buf.WriteString(d)
} else {
buf.WriteRune(c)
}
}
return buf.String()
} | go | {
"resource": ""
} |
q171233 | Parse | validation | func Parse() error {
args := os.Args
if len(args) == 1 {
return nil
}
// Global flags.
fset := flag.CommandLine
fset.Usage = Usage
out := fsetOutput(fset)
if err := fset.Parse(args[1:]); err != nil {
return err
}
// Handle version request.
if f := fset.Lookup(VersionBoolFlag); f != nil {
if v, ok :=... | go | {
"resource": ""
} |
q171234 | Sum | validation | func (xxh XXHZero) Sum(b []byte) []byte {
h32 := xxh.Sum32()
return append(b, byte(h32), byte(h32>>8), byte(h32>>16), byte(h32>>24))
} | go | {
"resource": ""
} |
q171235 | Reset | validation | func (xxh *XXHZero) Reset() {
xxh.v1 = prime32_1plus2
xxh.v2 = prime32_2
xxh.v3 = 0
xxh.v4 = prime32_minus1
xxh.totalLen = 0
xxh.bufused = 0
} | go | {
"resource": ""
} |
q171236 | Write | validation | func (xxh *XXHZero) Write(input []byte) (int, error) {
if xxh.totalLen == 0 {
xxh.Reset()
}
n := len(input)
m := xxh.bufused
xxh.totalLen += uint64(n)
r := len(xxh.buf) - m
if n < r {
copy(xxh.buf[m:], input)
xxh.bufused += len(input)
return n, nil
}
p := 0
// Causes compiler to work directly from ... | go | {
"resource": ""
} |
q171237 | Sum32 | validation | func (xxh *XXHZero) Sum32() uint32 {
h32 := uint32(xxh.totalLen)
if h32 >= 16 {
h32 += rol1(xxh.v1) + rol7(xxh.v2) + rol12(xxh.v3) + rol18(xxh.v4)
} else {
h32 += prime32_5
}
p := 0
n := xxh.bufused
buf := xxh.buf
for n := n - 4; p <= n; p += 4 {
h32 += binary.LittleEndian.Uint32(buf[p:p+4]) * prime32_3
... | go | {
"resource": ""
} |
q171238 | ChecksumZero | validation | func ChecksumZero(input []byte) uint32 {
n := len(input)
h32 := uint32(n)
if n < 16 {
h32 += prime32_5
} else {
v1 := prime32_1plus2
v2 := prime32_2
v3 := uint32(0)
v4 := prime32_minus1
p := 0
for n := n - 16; p <= n; p += 16 {
sub := input[p:][:16] //BCE hint for compiler
v1 = rol13(v1+binary.... | go | {
"resource": ""
} |
q171239 | Uint32Zero | validation | func Uint32Zero(x uint32) uint32 {
h := prime32_5 + 4 + x*prime32_3
h = rol17(h) * prime32_4
h ^= h >> 15
h *= prime32_2
h ^= h >> 13
h *= prime32_3
h ^= h >> 16
return h
} | go | {
"resource": ""
} |
q171240 | UncompressBlock | validation | func UncompressBlock(src, dst []byte) (di int, err error) {
sn := len(src)
if sn == 0 {
return 0, nil
}
di = decodeBlock(dst, src)
if di < 0 {
return 0, ErrInvalidSourceShortBuffer
}
return di, nil
} | go | {
"resource": ""
} |
q171241 | NewReader | validation | func NewReader(src io.Reader) *Reader {
r := &Reader{src: src}
return r
} | go | {
"resource": ""
} |
q171242 | Reset | validation | func (z *Reader) Reset(r io.Reader) {
z.Header = Header{}
z.pos = 0
z.src = r
z.zdata = z.zdata[:0]
z.data = z.data[:0]
z.idx = 0
z.checksum.Reset()
} | go | {
"resource": ""
} |
q171243 | readUint32 | validation | func (z *Reader) readUint32() (uint32, error) {
buf := z.buf[:4]
_, err := io.ReadFull(z.src, buf)
x := binary.LittleEndian.Uint32(buf)
return x, err
} | go | {
"resource": ""
} |
q171244 | Write | validation | func (z *Writer) Write(buf []byte) (int, error) {
if !z.Header.done {
if err := z.writeHeader(); err != nil {
return 0, err
}
}
if debugFlag {
debug("input buffer len=%d index=%d", len(buf), z.idx)
}
zn := len(z.data)
var n int
for len(buf) > 0 {
if z.idx == 0 && len(buf) >= zn {
// Avoid a copy a... | go | {
"resource": ""
} |
q171245 | compressBlock | validation | func (z *Writer) compressBlock(data []byte) error {
if !z.NoChecksum {
z.checksum.Write(data)
}
// The compressed block size cannot exceed the input's.
var zn int
var err error
if level := z.Header.CompressionLevel; level != 0 {
zn, err = CompressBlockHC(data, z.zdata, level)
} else {
zn, err = CompressB... | go | {
"resource": ""
} |
q171246 | Flush | validation | func (z *Writer) Flush() error {
if debugFlag {
debug("flush with index %d", z.idx)
}
if z.idx == 0 {
return nil
}
if err := z.compressBlock(z.data[:z.idx]); err != nil {
return err
}
z.idx = 0
return nil
} | go | {
"resource": ""
} |
q171247 | Close | validation | func (z *Writer) Close() error {
if !z.Header.done {
if err := z.writeHeader(); err != nil {
return err
}
}
if err := z.Flush(); err != nil {
return err
}
if debugFlag {
debug("writing last empty block")
}
if err := z.writeUint32(0); err != nil {
return err
}
if !z.NoChecksum {
checksum := z.c... | go | {
"resource": ""
} |
q171248 | Reset | validation | func (z *Writer) Reset(w io.Writer) {
z.Header = Header{}
z.dst = w
z.checksum.Reset()
z.zdata = z.zdata[:0]
z.data = z.data[:0]
z.idx = 0
} | go | {
"resource": ""
} |
q171249 | writeUint32 | validation | func (z *Writer) writeUint32(x uint32) error {
buf := z.buf[:4]
binary.LittleEndian.PutUint32(buf, x)
_, err := z.dst.Write(buf)
return err
} | go | {
"resource": ""
} |
q171250 | Uncompress | validation | func Uncompress(_ *flag.FlagSet) cmdflag.Handler {
return func(args ...string) error {
zr := lz4.NewReader(nil)
// Use stdin/stdout if no file provided.
if len(args) == 0 {
zr.Reset(os.Stdin)
_, err := io.Copy(os.Stdout, zr)
return err
}
for _, zfilename := range args {
// Input file.
zfile,... | go | {
"resource": ""
} |
q171251 | Compress | validation | func Compress(fs *flag.FlagSet) cmdflag.Handler {
var blockMaxSize string
fs.StringVar(&blockMaxSize, "size", "4M", "block max size [64K,256K,1M,4M]")
var blockChecksum bool
fs.BoolVar(&blockChecksum, "bc", false, "enable block checksum")
var streamChecksum bool
fs.BoolVar(&streamChecksum, "sc", false, "disable s... | go | {
"resource": ""
} |
q171252 | Fuzz | validation | func Fuzz(data []byte) int {
// uncompress some data
d, err := ioutil.ReadAll(lz4.NewReader(bytes.NewReader(data)))
if err != nil {
return 0
}
// got valid compressed data
// compress the uncompressed data
// and compare with the original input
buf := bytes.NewBuffer(nil)
zw := lz4.NewWriter(buf)
n, err :=... | go | {
"resource": ""
} |
q171253 | NewClient | validation | func NewClient(address, path string, eventBus Bus) *Client {
client := new(Client)
client.eventBus = eventBus
client.address = address
client.path = path
client.service = &ClientService{client, &sync.WaitGroup{}, false}
return client
} | go | {
"resource": ""
} |
q171254 | Subscribe | validation | func (client *Client) Subscribe(topic string, fn interface{}, serverAddr, serverPath string) {
client.doSubscribe(topic, fn, serverAddr, serverPath, Subscribe)
} | go | {
"resource": ""
} |
q171255 | Start | validation | func (client *Client) Start() error {
var err error
service := client.service
if !service.started {
server := rpc.NewServer()
server.Register(service)
server.HandleHTTP(client.path, "/debug"+client.path)
l, err := net.Listen("tcp", client.address)
if err == nil {
service.wg.Add(1)
service.started = t... | go | {
"resource": ""
} |
q171256 | PushEvent | validation | func (service *ClientService) PushEvent(arg *ClientArg, reply *bool) error {
service.client.eventBus.Publish(arg.Topic, arg.Args...)
*reply = true
return nil
} | go | {
"resource": ""
} |
q171257 | New | validation | func New() Bus {
b := &EventBus{
make(map[string][]*eventHandler),
sync.Mutex{},
sync.WaitGroup{},
}
return Bus(b)
} | go | {
"resource": ""
} |
q171258 | doSubscribe | validation | func (bus *EventBus) doSubscribe(topic string, fn interface{}, handler *eventHandler) error {
bus.lock.Lock()
defer bus.lock.Unlock()
if !(reflect.TypeOf(fn).Kind() == reflect.Func) {
return fmt.Errorf("%s is not of type reflect.Func", reflect.TypeOf(fn).Kind())
}
bus.handlers[topic] = append(bus.handlers[topic]... | go | {
"resource": ""
} |
q171259 | Subscribe | validation | func (bus *EventBus) Subscribe(topic string, fn interface{}) error {
return bus.doSubscribe(topic, fn, &eventHandler{
reflect.ValueOf(fn), false, false, false, sync.Mutex{},
})
} | go | {
"resource": ""
} |
q171260 | HasCallback | validation | func (bus *EventBus) HasCallback(topic string) bool {
bus.lock.Lock()
defer bus.lock.Unlock()
_, ok := bus.handlers[topic]
if ok {
return len(bus.handlers[topic]) > 0
}
return false
} | go | {
"resource": ""
} |
q171261 | Unsubscribe | validation | func (bus *EventBus) Unsubscribe(topic string, handler interface{}) error {
bus.lock.Lock()
defer bus.lock.Unlock()
if _, ok := bus.handlers[topic]; ok && len(bus.handlers[topic]) > 0 {
bus.removeHandler(topic, bus.findHandlerIdx(topic, reflect.ValueOf(handler)))
return nil
}
return fmt.Errorf("topic %s doesn'... | go | {
"resource": ""
} |
q171262 | Publish | validation | func (bus *EventBus) Publish(topic string, args ...interface{}) {
bus.lock.Lock() // will unlock if handler is not found or always after setUpPublish
defer bus.lock.Unlock()
if handlers, ok := bus.handlers[topic]; ok && 0 < len(handlers) {
// Handlers slice may be changed by removeHandler and Unsubscribe during it... | go | {
"resource": ""
} |
q171263 | NewNetworkBus | validation | func NewNetworkBus(address, path string) *NetworkBus {
bus := new(NetworkBus)
bus.sharedBus = New()
bus.Server = NewServer(address, path, bus.sharedBus)
bus.Client = NewClient(address, path, bus.sharedBus)
bus.service = &NetworkBusService{&sync.WaitGroup{}, false}
bus.address = address
bus.path = path
return bu... | go | {
"resource": ""
} |
q171264 | Start | validation | func (networkBus *NetworkBus) Start() error {
var err error
service := networkBus.service
clientService := networkBus.Client.service
serverService := networkBus.Server.service
if !service.started {
server := rpc.NewServer()
server.RegisterName("ServerService", serverService)
server.RegisterName("ClientServic... | go | {
"resource": ""
} |
q171265 | NewServer | validation | func NewServer(address, path string, eventBus Bus) *Server {
server := new(Server)
server.eventBus = eventBus
server.address = address
server.path = path
server.subscribers = make(map[string][]*SubscribeArg)
server.service = &ServerService{server, &sync.WaitGroup{}, false}
return server
} | go | {
"resource": ""
} |
q171266 | HasClientSubscribed | validation | func (server *Server) HasClientSubscribed(arg *SubscribeArg) bool {
if topicSubscribers, ok := server.subscribers[arg.Topic]; ok {
for _, topicSubscriber := range topicSubscribers {
if *topicSubscriber == *arg {
return true
}
}
}
return false
} | go | {
"resource": ""
} |
q171267 | Start | validation | func (server *Server) Start() error {
var err error
service := server.service
if !service.started {
rpcServer := rpc.NewServer()
rpcServer.Register(service)
rpcServer.HandleHTTP(server.path, "/debug"+server.path)
l, e := net.Listen("tcp", server.address)
if e != nil {
err = e
fmt.Errorf("listen error... | go | {
"resource": ""
} |
q171268 | Register | validation | func (service *ServerService) Register(arg *SubscribeArg, success *bool) error {
subscribers := service.server.subscribers
if !service.server.HasClientSubscribed(arg) {
rpcCallback := service.server.rpcCallback(arg)
switch arg.SubscribeType {
case Subscribe:
service.server.eventBus.Subscribe(arg.Topic, rpcCa... | go | {
"resource": ""
} |
q171269 | Valid | validation | func (p GTLDPeriod) Valid(when time.Time) error {
// NOTE: We can throw away the errors from time.Parse in this function because
// the zlint-gtld-update command only writes entries to the generated gTLD map
// after the dates have been verified as parseable
notBefore, _ := time.Parse(GTLDPeriodDateFormat, p.Delega... | go | {
"resource": ""
} |
q171270 | HasValidTLD | validation | func HasValidTLD(domain string, when time.Time) bool {
labels := strings.Split(strings.ToLower(domain), ".")
rightLabel := labels[len(labels)-1]
// if the rightmost label is not present in the tldMap, it isn't valid and
// never was.
if tldPeriod, present := tldMap[rightLabel]; !present {
return false
} else if... | go | {
"resource": ""
} |
q171271 | IsInTLDMap | validation | func IsInTLDMap(label string) bool {
label = strings.ToLower(label)
if _, ok := tldMap[label]; ok {
return true
} else {
return false
}
} | go | {
"resource": ""
} |
q171272 | Execute | validation | func (l *arpaMalformedIP) Execute(c *x509.Certificate) *LintResult {
for _, name := range c.DNSNames {
name = strings.ToLower(name)
var err error
if strings.HasSuffix(name, rdnsIPv4Suffix) {
// If the name has the in-addr.arpa suffix then it should be an IPv4 reverse
// DNS name.
err = lintReversedIPAdd... | go | {
"resource": ""
} |
q171273 | lintReversedIPAddressLabels | validation | func lintReversedIPAddressLabels(name string, ipv6 bool) error {
numRequiredLabels := rdnsIPv4Labels
zoneSuffix := rdnsIPv4Suffix
if ipv6 {
numRequiredLabels = rdnsIPv6Labels
zoneSuffix = rdnsIPv6Suffix
}
// Strip off the zone suffix to get only the reversed IP address
ipName := strings.TrimSuffix(name, zon... | go | {
"resource": ""
} |
q171274 | CheckRDNSequenceWhiteSpace | validation | func CheckRDNSequenceWhiteSpace(raw []byte) (leading, trailing bool, err error) {
var seq pkix.RDNSequence
if _, err = asn1.Unmarshal(raw, &seq); err != nil {
return
}
for _, rdn := range seq {
for _, atv := range rdn {
if !IsNameAttribute(atv.Type) {
continue
}
value, ok := atv.Value.(string)
i... | go | {
"resource": ""
} |
q171275 | IsIA5String | validation | func IsIA5String(raw []byte) bool {
for _, b := range raw {
i := int(b)
if i > 127 || i < 0 {
return false
}
}
return true
} | go | {
"resource": ""
} |
q171276 | AllAlternateNameWithTagAreIA5 | validation | func AllAlternateNameWithTagAreIA5(ext *pkix.Extension, tag int) (bool, error) {
var seq asn1.RawValue
var err error
// Unmarshal the extension as a sequence
if _, err = asn1.Unmarshal(ext.Value, &seq); err != nil {
return false, err
}
// Ensure the sequence matches what we expect for SAN/IAN
if !seq.IsCompoun... | go | {
"resource": ""
} |
q171277 | IsEV | validation | func IsEV(in []asn1.ObjectIdentifier) bool {
for _, oid := range in {
if _, ok := evoids[oid.String()]; ok {
return true
}
}
return false
} | go | {
"resource": ""
} |
q171278 | Execute | validation | func (l *onionNotEV) Execute(c *x509.Certificate) *LintResult {
/*
* Effective May 1, 2015, each CA SHALL revoke all unexpired Certificates with an
* Internal Name using onion as the right-most label in an entry in the
* subjectAltName Extension or commonName field unless such Certificate was
* issued in accor... | go | {
"resource": ""
} |
q171279 | getData | validation | func getData(url string) ([]byte, error) {
resp, err := httpClient.Get(url)
if err != nil {
return nil, fmt.Errorf("unable to fetch data from %q : %s",
url, err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("unexpected status code fetching data "+
"from %q : exp... | go | {
"resource": ""
} |
q171280 | getGTLDData | validation | func getGTLDData() ([]util.GTLDPeriod, error) {
respBody, err := getData(ICANN_GTLD_JSON)
if err != nil {
return nil, fmt.Errorf("error getting ICANN gTLD JSON : %s", err)
}
var results struct {
GTLDs []util.GTLDPeriod
}
if err := json.Unmarshal(respBody, &results); err != nil {
return nil, fmt.Errorf("une... | go | {
"resource": ""
} |
q171281 | delegatedGTLDs | validation | func delegatedGTLDs(entries []util.GTLDPeriod) []util.GTLDPeriod {
var results []util.GTLDPeriod
for _, gTLD := range entries {
if gTLD.DelegationDate == "" {
continue
}
results = append(results, gTLD)
}
return results
} | go | {
"resource": ""
} |
q171282 | validateGTLDs | validation | func validateGTLDs(entries []util.GTLDPeriod) error {
for _, gTLD := range entries {
// All entries should have a valid delegation date
if _, err := time.Parse(util.GTLDPeriodDateFormat, gTLD.DelegationDate); err != nil {
return err
}
// a gTLD that has not been removed has an empty RemovalDate and that's O... | go | {
"resource": ""
} |
q171283 | init | validation | func init() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s [flags]\n", os.Args[0])
flag.PrintDefaults()
}
flag.Parse()
log.SetLevel(log.InfoLevel)
} | go | {
"resource": ""
} |
q171284 | IsNameAttribute | validation | func IsNameAttribute(oid asn1.ObjectIdentifier) bool {
if len(oid) != 4 {
return false
}
if !nameAttributePrefix.Equal(oid[0:3]) {
return false
}
_, ok := nameAttributeLeaves[oid[3]]
return ok
} | go | {
"resource": ""
} |
q171285 | MarshalJSON | validation | func (e LintStatus) MarshalJSON() ([]byte, error) {
s := e.String()
return json.Marshal(s)
} | go | {
"resource": ""
} |
q171286 | String | validation | func (e LintStatus) String() string {
switch e {
case NA:
return "NA"
case NE:
return "NE"
case Pass:
return "pass"
case Notice:
return "info"
case Warn:
return "warn"
case Error:
return "error"
case Fatal:
return "fatal"
default:
return ""
}
} | go | {
"resource": ""
} |
q171287 | EncodeLintDescriptionsToJSON | validation | func EncodeLintDescriptionsToJSON(w io.Writer) {
enc := json.NewEncoder(w)
enc.SetEscapeHTML(false)
for _, lint := range lints.Lints {
enc.Encode(lint)
}
} | go | {
"resource": ""
} |
q171288 | LintCertificate | validation | func LintCertificate(c *x509.Certificate) *ResultSet {
// Instead of panicing on nil certificate, just returns nil and let the client
// panic when accessing ZLint, if they're into panicing.
if c == nil {
return nil
}
// Run all tests
res := new(ResultSet)
res.execute(c)
res.Version = Version
res.Timestamp ... | go | {
"resource": ""
} |
q171289 | CheckApplies | validation | func (l *torValidityTooLarge) CheckApplies(c *x509.Certificate) bool {
return util.IsSubscriberCert(c) && util.CertificateSubjInTLD(c, onionTLD)
} | go | {
"resource": ""
} |
q171290 | failResult | validation | func failResult(format string, args ...interface{}) *LintResult {
return &LintResult{
Status: Error,
Details: fmt.Sprintf(format, args...),
}
} | go | {
"resource": ""
} |
q171291 | CheckEffective | validation | func (l *Lint) CheckEffective(c *x509.Certificate) bool {
if l.EffectiveDate.IsZero() || !l.EffectiveDate.After(c.NotBefore) {
return true
}
return false
} | go | {
"resource": ""
} |
q171292 | GetExtFromCert | validation | func GetExtFromCert(cert *x509.Certificate, oid asn1.ObjectIdentifier) *pkix.Extension {
for i := range cert.Extensions {
if oid.Equal(cert.Extensions[i].Id) {
return &(cert.Extensions[i])
}
}
return nil
} | go | {
"resource": ""
} |
q171293 | TypeInName | validation | func TypeInName(name *pkix.Name, oid asn1.ObjectIdentifier) bool {
for _, v := range name.Names {
if oid.Equal(v.Type) {
return true
}
}
return false
} | go | {
"resource": ""
} |
q171294 | GetMappedPolicies | validation | func GetMappedPolicies(polMap *pkix.Extension) (out [][2]asn1.ObjectIdentifier, err error) {
if polMap == nil {
return nil, errors.New("policyMap: null pointer")
}
var outSeq, inSeq asn1.RawValue
empty, err := asn1.Unmarshal(polMap.Value, &outSeq) //strip outer sequence tag/length should be nothing extra
if err... | go | {
"resource": ""
} |
q171295 | printJSON | validation | func printJSON(v interface{}) {
w := json.NewEncoder(os.Stdout)
w.SetIndent("", "\t")
err := w.Encode(v)
if err != nil {
panic(err)
}
} | go | {
"resource": ""
} |
q171296 | UnmarshalJSON | validation | func (u *URI) UnmarshalJSON(data []byte) error {
// Ignore null, like in the main JSON package.
if string(data) == "null" {
return nil
}
var s string
err := json.Unmarshal(data, &s)
if err != nil {
return err
}
u.URL, err = url.Parse(s)
return err
} | go | {
"resource": ""
} |
q171297 | NewClient | validation | func NewClient(httpClient *http.Client) *Client {
return &Client{
client: graphql.NewClient("https://api.github.com/graphql", httpClient),
}
} | go | {
"resource": ""
} |
q171298 | NewEnterpriseClient | validation | func NewEnterpriseClient(url string, httpClient *http.Client) *Client {
return &Client{
client: graphql.NewClient(url, httpClient),
}
} | go | {
"resource": ""
} |
q171299 | Query | validation | func (c *Client) Query(ctx context.Context, q interface{}, variables map[string]interface{}) error {
return c.client.Query(ctx, q, variables)
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.