text
stringlengths
11
4.05M
package main import ( "reflect" "fmt" ) type ExecutionServiceServer interface { Create(string, string) (string, error) Start(string, string) (string, error) Update(string, string) (string, error) Pause(string, string) (string, error) Resume(string, string) (string, error) Delete(string, string) (...
package qsort import "testing" func TestQuickSort(t *testing.T) { values := []int{5, 3, 6, 1, 0, 4} QuickSort(values) if values[0] != 0 || values[1] != 1 || values[2] != 3 || values[3] != 4 || values[4] != 5 || values[5] != 6 { t.Error("quicksort error got: ", values, "excepted 0 1 3 4 5 6") } }
package arrayList import () const( ) type ArrayList struct { capacity, size int data []interface{} } func NewList() *ArrayList { return &ArrayList{ capacity: 10, size: 0, data: make([]interface{}, 12), } } func (list *ArrayList) Add(data interface{}) { if list.size < list.capacity { ...
package main import ( "github.com/mkrou/fetcher/fetcher" "log" "sync" ) func main() { mock := fetcher.NewFetcher(2) wait := sync.WaitGroup{} for i := 0; i < 10; i++ { wait.Add(2) go func() { printFetchedData(mock.Get()) wait.Done() }() go func() { printFetchedData(mock.List()) wait.Done(...
package client import ( "bufio" "encoding/binary" "errors" "io" "os" "path" "strings" "gopl/8_2/ftp" ) type FtpClient struct { ftp.FtpConn } func (ftpCon *FtpClient) WriteCommand(cmdid uint8, args []string) error { if cmdid == ftp.Commands["put"] { return ftpCon.WritePut(cmdid, args[...
package main import ( "fmt" "os" "example.com/hello/echo" "example.com/hello/tempconv" ) const PI = 3.1415 func main() { // var r = 10.0 // var area = PI * r * r // fmt.Printf("面积为:%g", area) // fmt.Println() // var i int // var b bool // var s string // fmt.Printf("i: %v, b: %v, s: %v", i, b, ...
package main /* import "arnested.dk/go/healthy" */ import ( "context" "flag" "fmt" "os" "time" "github.com/docker/docker/client" "github.com/pkg/errors" ) func main() { failOnUnhealthy := flag.Bool("fail-on-unhealthy", false, "fail on unhealthy") flag.Parse() cli, err := client.NewEnvClient() if err != n...
// Package database deals with the initialization // of our database connection. package database import ( "database/sql" "fmt" "log" "os" "strings" "time" "github.com/MangoHacks/Mango2019-API/models" // Database driver. _ "github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/postgres" _ "github.com...
package partical //给定一个二叉树,判断其是否是一个有效的二叉搜索树。 // // 假设一个二叉搜索树具有如下特征: // // // 节点的左子树只包含小于当前节点的数。 // 节点的右子树只包含大于当前节点的数。 // 所有左子树和右子树自身必须也是二叉搜索树。 // // // 示例 1: // // 输入: // 2 // / \ // 1 3 //输出: true // // // 示例 2: // // 输入: // 5 // / \ // 1 4 //  / \ //  3 6 //输出: false //解释: 输入为: [5,1,4,null,nul...
// Copyright (C) 2016-Present Pivotal Software, Inc. All rights reserved. // This program and the accompanying materials are made available under the terms of the under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. // You may obtain a copy of the Licen...
package recursion import ( "AlgorizmiGo/recursion" "github.com/stretchr/testify/assert" "testing" ) func TestStackUnwind(t *testing.T) { recursion.StackUnwind(5) } func TestRecursionWithDataCaches(t *testing.T) { recursion.RecursionWithDataCaches(5) } func TestForwardIterationViaRecursion(t *testing.T) { input...
package core import ( "compress/zlib" "fmt" "io" ) func Compress(r io.Reader) io.Reader { zpr, zpw := io.Pipe() //var rbuf = make([]byte, 32 * 1024) writer, err := zlib.NewWriterLevel(zpw, zlib.BestCompression) if err != nil { return nil } go func() { fmt.Printf(...
// Copyright 2021 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package businessmoment import ( platformK8s "github.com/dolittle/platform-api/pkg/platform/k8s" "github.com/dolittle/platform-api/pkg/platform/microservice/businessmomentsadaptor" "github.com/dolittle/platform-api/pkg/platform/storage" "github.com/sirupsen/logrus" "k8s.io/client-go/kubernetes" ) type service str...
// Copyright 2019 Yunion // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writi...
package taskmanapi import ( "encoding/json" "encoding/base64" "io" "net/http" "math/rand" "time" "crypto/sha1" ) func recvJSON(r io.ReadCloser) (map[string]interface{}, error) { data := make(map[string]interface{}) return data, json.NewDecoder(r).Decode(&data) } func sendJSON(w http.ResponseWriter,...
package conf import ( "path/filepath" "github.com/BurntSushi/toml" "go.uber.org/zap" "gogit.oa.com/March/gopkg/logger" "gogit.oa.com/March/gopkg/util" ) var L *zap.Logger var Conf = struct { App struct { Env string } Log struct { Tag string Addr string Level int } Client struct { Addr string ...
// Copyright 2021 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // TODO(crbug/1142830) - Change all native terms when Android's subcomponents // name are changed. // Modify the filename to match...
package cache import ( "time" . "openreplay/backend/pkg/db/types" ) func (c *PGCache) GetProjectByKey(projectKey string) (*Project, error) { if c.projectsByKeys[ projectKey ] != nil && time.Now().Before(c.projectsByKeys[ projectKey ].expirationTime) { return c.projectsByKeys[ projectKey ].Project, nil } p,...
package messages import ( "../../tools" "../../types" ) func StatusText(str string) types.Message { var outMsg types.Message outMsg.Type = 0x09 payload := tools.Int32ToBytes(1) payload = append(payload, tools.GetEncodedString(str) ...) outMsg.Payload = payload outMsg.Length = int16(len(outMsg.Payload) + 3) r...
package main import ( "os" "github.com/tinyzimmer/k3p/pkg/cmd" "github.com/tinyzimmer/k3p/pkg/log" ) func main() { if err := cmd.GetRootCommand().Execute(); err != nil { log.Error(err) os.Exit(1) } }
// Copyright (C) 2017 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed t...
package service import ( "context" "go.mongodb.org/mongo-driver/bson" "jxc/models" ) // 获取子订单实例列表 func FindSubOrderInstance(subOrderId int64, comId int64) ([]models.GoodsInstance, error) { collection := models.Client.Collection("goods_instance") var instance models.GoodsInstance var instanceArr []models.GoodsIn...
package main import ( "fmt" "testing" ) func Test_main(t *testing.T) { main() } func x1(x int) int { return x + 1 } func Test_applyIt(t *testing.T) { // anonymous function fmt.Println(applyIt(func(x int) int { return x + 1 }, 7)) // defined function fmt.Println(applyIt(x1, 2)) // variable as a function n :...
package main import ( "container/list" "time" ) type job_mode int const ( JOB_MODE_RUNNABLE job_mode = iota JOB_MODE_BLOCK JOB_MODE_IDLE ) type Job struct { s *Scheduler next, prev *Job mode job_mode parallel_abs uint parallel int priority int Name string RunNum int OldNum int No...
package client import ( "context" "encoding/json" "reflect" "github.com/mr-tron/base58" ma "github.com/multiformats/go-multiaddr" "github.com/textileio/go-textile-core/crypto/symmetric" pb "github.com/textileio/go-textile-threads/api/pb" es "github.com/textileio/go-textile-threads/eventstore" "github.com/tex...
package mapreduce import ( "fmt" "sync" ) // schedule starts and waits for all tasks in the given phase (Map or Reduce). func (mr *Master) schedule(phase jobPhase) { var ntasks int var nios int // number of inputs (for reduce) or outputs (for map) switch phase { case mapPhase: ntasks = len(mr.files) nios = ...
// Package web contains many functions and structs that are common // to applications and services that interact via the internet. package web import ( "encoding/json" "fmt" "log" "net/http" ) // HTTPErrors // // These which arise from HTTP requests and responses. // It's useful to provide the user with these err...
package smartling // Credentials represents represents user credentials used to authenticate // user in the Smartling API. type Credentials struct { // UserID is a unique user ID for accessing Smartling API. UserID string // Secret is a secret token for accessing Smartling API. Secret string // AccessToken is a...
/* Copyright 2018 Turbine Labs, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, softw...
package ctrls import ( "net/http" "encoding/json" "io/ioutil" "log" "github.com/qowns8/sample-web/models" "github.com/qowns8/sample-web/utils" ) func UserRegisteration(w http.ResponseWriter, r *http.Request) { body, _ := ioutil.ReadAll(r.Body) createLoginFormDate := utils.CreateLoginFormDate{} jsEerr := jso...
// Copyright (C) 2017 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed t...
package handlers import ( "wayneli.me/m/servers/gateway/models/users" "wayneli.me/m/servers/gateway/sessions" ) // This is the struct declaration for HandlerContext type HandlerContext struct { SigningKey string SessionsStore sessions.Store UsersStore users.Store }
package concourse_test import ( "github.com/kkallday/one-off/concourse" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) const ( oldPipelineYAML = ` groups: - name: some-pipeline-name jobs: - some-job resources: - name: some-resource type: git jobs: - name: some-job plan: - aggregate: - get:...
package zrpc import ( "log" "net" "net/http" "os" "os/signal" "sync" "syscall" "time" ) // Proxy 代理伺服 type Proxy struct { PrefixPath string Services map[string]Service HTTPAddr string HTTPNet net.Listener HTTPServer *http.Server timeout int64 ui bool debug bool mx *sync...
package restmapping import ( "context" "fmt" "strconv" "github.com/adamluzsi/frameless/ports/crud/extid" ) type SetIDByExtIDTag[Entity, ID any] struct{} func (m SetIDByExtIDTag[Entity, ID]) LookupID(ent Entity) (ID, bool) { return extid.Lookup[ID](ent) } func (m SetIDByExtIDTag[Entity, ID]) SetID(ptr *Entity,...
// Common data file features - enlarge, close, sync, close, etc. package data import ( "github.com/HouzuoGuo/tiedot/gommap" "github.com/HouzuoGuo/tiedot/tdlog" "os" ) // Data file keeps track of the amount of total and used space. type DataFile struct { Path string Size, Used, Growth int Fh ...
// Copyright 2019 The gVisor Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
package syncutils type KRWMutex struct { keyMutexConsumers map[interface{}]int keyMutexes map[interface{}]*RWMutex mutex RWMutex } func NewKRWMutex() *KRWMutex { return &KRWMutex{ keyMutexConsumers: make(map[interface{}]int), keyMutexes: make(map[interface{}]*RWMutex), } } func (k ...
package ewkb import ( "bytes" "encoding/binary" "encoding/hex" "errors" "io" "github.com/paulmach/orb" "github.com/paulmach/orb/encoding/internal/wkbcommon" ) var ( // ErrUnsupportedDataType is returned by Scan methods when asked to scan // non []byte data from the database. This should never happen // if ...
package dao import ( "fmt" "strconv" "strings" ) type Book struct { Id int UserName string Name string Author string Describe string Img string ModifiedTime string Count int Status int /*0 init or returned ; 1 send borrow request; 2 accept borrow ...
/* Copyright © 2019 Matthieu MARTIN <matthieu@agence-webup.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, m...
package storage import ( "testing" ) func TestCreateImageRepo(t *testing.T) { params := make(map[string]string) if err := CreateImageRepo("", params); err == nil { t.Errorf("CreateImageRepo did not fail when no region was provided") } params["region"] = "" if err := CreateImageRepo("", params); err == nil { ...
package Valid_Mountain_Array func validMountainArray(a []int) bool { i, n := 0, len(a) // 递增扫描 for ; i+1 < n && a[i] < a[i+1]; i++ { } // 最高点不能是数组的第一个位置或最后一个位置 if i == 0 || i == n-1 { return false } // 递减扫描 for ; i+1 < n && a[i] > a[i+1]; i++ { } return i == n-1 }
// http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#field-lists // https://siongui.github.io/2016/02/03/go-iterate-over-utf8-non-ascii-string/ package rst import ( "errors" "strings" ) type RstFieldList struct { FieldName string FieldBody []string indexOfFirstLine int indexOfLast...
package sinks type ArraySink struct { arr []interface{} } func NewArraySink() *ArraySink { return &ArraySink{arr: nil} } func (this *ArraySink) Dump(object ...interface{}) error { this.arr = append(this.arr, object...) return nil } func (this *ArraySink) Close() error { return nil } func (this *ArraySink) Get...
package proxy import ( "bufio" "bytes" "context" "flag" "fmt" "io" "net" "net/http" "net/http/httptest" "strings" "sync" "testing" "time" "github.com/gobwas/ws/wsutil" gorillaWS "github.com/gorilla/websocket" "github.com/rs/zerolog" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/r...
// Copyright 2017 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package api import ( "bytes" "encoding/xml" "fmt" "gitee.com/xiaochengtech/wechat/constant" "gitee.com/xiaochengtech/wechat/util" "github.com/beevik/etree" "net/http" "sort" "strconv" "encoding/json" "errors" ) const ( // 返回结果 ResponseSuccess = "SUCCESS" // 成功,通信标识或业务结果 ResponseFail = "FAIL" // 失败...
// Copyright 2019 Contentsquare // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agre...
package v1 type UserLogin struct { Username string `json:"username"` Token string `json:"token"` ExpiresAt int64 `json:"expiresAt"` }
package typing import ( "sync" "time" ) type typing struct { user uint64 tm time.Time } type Typer struct { poller Poller users map[uint64][]typing lock sync.RWMutex stopper chan bool } type Poller interface { PushEvent(id uint64) } func (t *Typer) Cleaner() { for { select { case <-t.stopper: ...
// Package set implements a functional Set data structure. The internal data // structure of set is a Hashed Array Mapped Trie // (see https://en.wikipedia.org/wiki/Hash_array_mapped_trie). // // Functional means that each data structure is immutable and persistent. // The Set is immutable because you never modify a Se...
package model import ( "shared/common" "shared/utility/errors" ) // 返回值为false,代表执行成功,进度+1;返回值为true,代表进度已达上限,执行失败 func (g *Guild) YggCoBuildImprove(buildID int32, uid int64) (*YggCoBuild, bool, error) { coBuild, ok := g.YggCoBuilds[buildID] if !ok { return nil, false, errors.Swrapf(common.ErrGuildYggWrongIDForC...
package lc import "bytes" // Time: O(n) // Benchmark: 0ms 2.1mb | 100% func mergeAlternately(word1 string, word2 string) string { var buf bytes.Buffer for i := range word1 { buf.WriteByte(word1[i]) if i < len(word2) { buf.WriteByte(word2[i]) } } if len(word1) < len(word2) { buf.WriteString(word2[len(...
package main import "fmt" func convertToGcode(coordsArray [100][3]float64) [12]string { a := 1 var result [12]string fmt.Println(pointAmountCalc(gstig, hdyb)) result[0] = fmt.Sprint("G01 X", (coordsArray[0][0]), "\n") for a < pointAmountCalc(gstig, hdyb) { result[a] = fmt.Sprint("G02 X", coordsArray[a][0], " Y...
package main import ( "cltx/rpc" "cltx/UserRmbRpcDef" "fmt" "git.apache.org/thrift.git/lib/go/thrift" "github.com/golang/protobuf/proto" "net" "os" "time" ) func main() { startTime := currentTimeMillis() transportFactory := thrift.NewTFramedTransportFactory(thrift.NewTTransportFact...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package mgs import ( "context" "chromiumos/tast/common/fixture" "chromiumos/tast/common/media/caps" "chromiumos/tast/common/policy/fakedms" "chromiumos/tast/local/came...
package main import "fmt" func main() { //studyArr() //rangeArr() //pointArr() var arr [5]int = [5]int{1, 2, 3, 4, 5} fmt.Println(&arr[2]) //modifyArr(arr) modifyPointArr(&arr) } func studyArr() { var arr [5]int arr = [5]int{1, 2, 3, 4, 5} arr1 := [...]int{2, 3, 4, 5, 6} arr2 := [4]string{1: "hello", 3: "...
package main import ( "fmt" "net/http" "net/url" //"strconv" //"errors" "regexp" "strings" "time" mf "github.com/mixamarciv/gofncstd3000" //"html/template" ) //хендлер для /publish func http_publish(w http.ResponseWriter, r *http.Request) { d := http_parse_url(w, r) http_parse_url__get_db(w, r, d) if d...
// Copyright (c) 2018 Palantir Technologies. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless require...
// Copyright (C) 2020 Storj Labs, Inc. // See LICENSE for copying information. // Package identity implements CA and Peer identity management and generation. package identity
package activity import ( "context" "encoding/json" "net/http" "github.com/gorilla/mux" "fmt" ) type ( CreateActivityRequest struct { // ID string `json:"id,omitempty"` Name string `json:"name"` Category string `json:"category"` Location string `json:"location"` Date string `js...
package view import ( caos_errs "github.com/caos/zitadel/internal/errors" global_model "github.com/caos/zitadel/internal/model" proj_model "github.com/caos/zitadel/internal/project/model" "github.com/caos/zitadel/internal/project/repository/view/model" "github.com/caos/zitadel/internal/view/repository" "github.c...
package main import "errors" // Solution solve kata func Solution(str string, idx uint) (uint, error) { r := string(str[idx]) if r != "(" { return 0, errors.New("Not an opening bracket") } depth := 0 var res uint for i := int(idx) + 1; i < len(str); i++ { s := string(str[i]) if s == ")" { if depth == 0...
package tests import ( "fmt" "testing" ) /** * [78] Subsets * * Given a set of distinct integers, nums, return all possible subsets (the power set). * * Note: The solution set must not contain duplicate subsets. * * Example: * * * Input: nums = [1,2,3] * Output: * [ * [3], * [1], * [2...
package models type ItemOutcomingModel struct { ID int64 `json:"id"` ItemID int `json:"item_id,omitempty"` SKU string `json:"sku,omitempty"` ItemName string `json:"item_name,omitempty"` TotalOutcomingItem int `json:"total_outcoming_item,omitempty"` Sell...
package commands import ( "fmt" "github.com/SBanczyk/backup/backend/fs" "github.com/SBanczyk/backup/model" "os" "path" "path/filepath" ) func Get(currentDir string, paths []string) error { baseDir, err := checkBaseDir(currentDir) if err != nil { return err } stagingPath := path.Join(baseDir, ".backup", "s...
// Copyright 2020 cloudeng llc. All rights reserved. // Use of this source code is governed by the Apache-2.0 // license that can be found in the LICENSE file. package structdoc_test import ( "strings" "testing" "cloudeng.io/cmdutil/structdoc" ) type S2 struct { B float32 `tag:"bar"` } type S1 struct { A int `...
// Copyright 2020 Insolar Network Ltd. // All rights reserved. // This material is licensed under the Insolar License version 1.0, // available at https://github.com/insolar/block-explorer/blob/master/LICENSE.md. // +build unit package storage import ( "testing" "github.com/stretchr/testify/require" ) func TestG...
package cloudformation // AWSS3Bucket_ServerSideEncryptionRule AWS CloudFormation Resource (AWS::S3::Bucket.ServerSideEncryptionRule) // See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-serversideencryptionrule.html type AWSS3Bucket_ServerSideEncryptionRule struct { // Serv...
package sdf import ( "time" ) // Tween - type Tween struct { startTime time.Duration duration time.Duration v0, v1 int pval *int } // NewTween - func NewTween() *Tween { return &Tween{} } // Reset - func (o *Tween) Reset(pval *int, t0, dur time.Duration, v0, v1 int) { o.startTime = t0 o.duration = ...
package main import ( "context" "crypto/tls" "crypto/x509" "fmt" "io/ioutil" "net" "net/http" "net/url" "os" "time" "github.com/BlueIcarus/prometheus-es-adapter/pkg/elasticsearch" "github.com/BlueIcarus/prometheus-es-adapter/pkg/handlers" "github.com/BlueIcarus/prometheus-es-adapter/pkg/logger" "github....
package openx import ( "encoding/json" "testing" "github.com/prebid/openrtb/v19/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/adapters/adapterstest" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/asser...
/* Copyright 2019 The Skaffold Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, sof...
package e7 import ( "errors" "testing" "github.com/google/go-cmp/cmp" ) func TestAttribute_String(t *testing.T) { tests := []struct { in Attribute want string }{ {in: None, want: "none"}, {in: Fire, want: "fire"}, {in: Ice, want: "ice"}, {in: Earth, want: "wind"}, {in: Light, want: "light"}, {...
package version const Version = "0.11.5"
package main import ( "fmt" ) // Profil func main() { profil := struct { ID int Name string Age int Address string }{ ID: 1, Name: "Rachmad Kurniawan", Age: 26, Address: "Jakarta Barat", } fmt.Println(profil) fmt.Println("===========================") fmt.Printf("Nama \t: ...
package main import ( "fmt" ) type User struct { ID int Name string Age int } // func main() { // x := 123 // v := reflect.ValueOf(&x) // fmt.Println(v.Elem()) // v.Elem().SetInt(999) // fmt.Println(x) // } // func Set(o interface{}) { // v := reflect.ValueOf(o) // if v.Kind() == reflect.Ptr && !v.Ele...
package websocket import ( "context" "io" websession "zenhack.net/go/tempest/capnp/web-session" ) // WriterStream implements websession.WebSocketStream_Server by writing data to W. // Note: the raw websocket traffic is written, rather than the high-level websocket // messages (i.e. we do not interpret headers & i...
package etcd import ( svc "github.com/halivor/goutil/service" "go.etcd.io/etcd/mvcc/mvccpb" ) type data struct { event svc.EventType kv *mvccpb.KeyValue } func (x *data) Data() []byte { return x.kv.Value } func (x *data) Event() svc.EventType { return x.event } func (x *data) String() string { return stri...
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build linux || windows || darwin || freebsd // +build linux windows darwin freebsd package safesocket import ( "strings" ps "github.com/mi...
package lib import ( "fmt" "net/url" "os" "strconv" "strings" "time" mqtt "git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.golang.git" ) // // ParseOptionsURI parses URI in the following format: // tcp://username:password@127.0.0.1:1883/topic?clientID=...&clean=true&qos=0 // Keep in mind # should be expres...
package base type Config interface { // Load file Load(path string) bool // clear data Clear() }
package controllers import ( "github.com/astaxie/beego" "strings" "path" "github.com/zppvae/go-blog/utils" ) type BaseController struct { beego.Controller controllerName string actionName string userId int username string pageSize int64 allowUrl string noLayout bool } ...
package main import ( "log" "shared/protobuf/pb" ) func (c *Client) GuildInfo(req *pb.C2SGuildInfo) (*pb.S2CGuildInfo, error) { gameResp, err := c.Request(10501, req) if err != nil { log.Printf("RESP ERROR: GuildInfo request error: %+v", err) return nil, err } resp := &pb.S2CGuildInfo{} err = c.Handle(ga...
package v1alpha1 import ( "bufio" "bytes" "github.com/gogo/protobuf/jsonpb" "github.com/golang/protobuf/proto" istio "istio.io/api/rbac/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // +genclient // +genclient:noStatus // // +genclient:nonNamespaced // +k8s:deepcopy-gen:interfaces=k8s.io/apimachine...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package network import ( "context" "net" "time" "github.com/google/go-cmp/cmp" "chromiumos/tast/common/shillconst" "chromiumos/tast/ctxutil" "chromiumos/tast/local/...
package openrtb import ( "fmt" ) // BidRequest type represents a top-level object to send to buyers by an ad exchange server for an // opportunity to auction one or multiple impressions. // The "site" is unused and has been omitted. // See OpenRTB 2.3.1 Sec 3.2.1. //go:generate easyjson $GOFILE //easyjson:json type ...
package main import ( "strings" "testing" ) func TestTsuncon(t *testing.T) { msg, err := getContributions("johntitor") if err != nil { t.Fatal(err) } if !strings.Contains(msg, "ξ ゚⊿ ゚)ξ <") { t.Errorf("expected ξ ゚⊿ ゚)ξ < something, got=%s", msg) } }
package chord import ( // "fmt" // "testing" // "time" ) // -------- Create Node / Create Defined Node ------------ // func TestCreateNodeSingleNode(t *testing.T) { // node, err := CreateNode(nil) // if err != nil { // t.Errorf("Unable to create node, received error:%v\n", err) // } // node2, err := Create...
package repo import ( "errors" "log" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/dynamodb" "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute" "github.com/aws/aws-sdk-go/service/dynamodb/expression" "github.com/google/uuid" ) type Group struct { ID string `dynamodbav:"I...
package main import ( "encoding/json" "errors" "io/ioutil" ) type Config struct { Email string `json:"Email"` Password string `json:"Password"` ServerUrl string `json:"ServerUrl"` OssUrl string `json:"OssUrl"` EnableSnoreToast bool `json:"EnableSnoreToast"` SnoreToastPat...
/* Copyright 2021 The KodeRover Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, s...
package request import ( "testing" "net/http" ) func TestRequest_DockerSocket(t *testing.T){ client := NewClient() response, err := client.Get("http://v1.37/_ping") if err != nil { t.Logf("Docker Socket Error %v",err) } if response.StatusCode != http.StatusOK{ t.Logf("Docker socket not running, %v",err) ...
package Opengl const ( vertexShaderSource = ` #version 330 core // Input vertex data, different for all executions of this shader. in vec3 vertexPosition_modelspace; in vec4 vertexColor; in vec2 vertexUV; in vec3 translation; in vec4 rotation; in vec3 scale; // Output data ; will be interpolated for each fragme...
package http_fetcher import ( "bytes" "context" "encoding/json" "fmt" "io" "net/http" "net/url" "strings" "github.com/prebid/prebid-server/stored_requests" jsonpatch "gopkg.in/evanphx/json-patch.v4" "github.com/golang/glog" "golang.org/x/net/context/ctxhttp" ) // NewFetcher returns a Fetcher which uses ...
package cpu import "testing" func (p *CPU) adc(first byte, second byte) { p.A = first p.Memory.Write(second, 0) p.Adc(0) } func TestZeroFlagSet(t *testing.T) { var p *CPU = NewCPU() p.adc(0x00, 0x00) if !p.Zero() { t.Errorf("Zero flag should be set when result is 0x00") } p...
package services import ( "fmt" "github.com/fatmalabidi/bookstore_users_api/domain/users" errH "github.com/fatmalabidi/bookstore_users_api/utils/error_handler" ) func GetUser(userID int64) (*users.User, *errH.RestErr) { if userID < 0 { return nil, errH.NewBadRequestError("invalid userID") } res := &users.User...