text stringlengths 11 4.05M |
|---|
package main
import "C"
func main() {}
//export Add
func Add(x int, y int) int {
return x + y
}
//export Subtract
func Subtract(x int, y int) int {
return x - y
}
|
/*
* Npcf_SMPolicyControl API
*
* Session Management Policy Control Service © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* API version: 1.0.4
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package openapi
// RedirectAddressType -... |
package http
import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"strconv"
)
func TestGetPopularBoardList(t *testing.T) {
usecase := NewMockUsecase()
delivery := NewHTTPDelivery(usecase)
req, err := http.NewRequest("GET", "/v1/popular-boards", nil)
if err != nil {
t.Fatal(err)
}
rr := htt... |
// Copyright 2014-2016 The Zurichess Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package engine
import . "bitbucket.org/zurichess/board"
// distance stores the number of king steps required
// to reach from one square to anothe... |
/**
* @Author: DollarKiller
* @Description: 抽象工厂模式
* @Github: https://github.com/dollarkillerx
* @Date: Create in 20:59 2019-09-16
*/
package main
type token interface {
} |
package main
import (
"fmt"
"reflect"
"testing"
)
func Test_run(t *testing.T) {
type args struct {
n, q int
a, k []int
}
tests := []struct {
args args
want []int
}{
{
args{4, 3, []int{3,5,6,7}, []int{2,5,3}},
[]int{2,9,4},
},
{
args{5, 2, []int{1,2,3,4,5}, []int{1,10}},
[]int{6,15},
... |
// SPDX-License-Identifier: MIT
package core
import (
"errors"
"os"
"testing"
"github.com/issue9/assert/v3"
"github.com/caixw/apidoc/v7/internal/locale"
)
var _ error = &Error{}
func TestError(t *testing.T) {
a := assert.New(t, false)
err1 := NewError("msg")
err2 := NewError("msg").WithField("field")
a.... |
package app
import (
"context"
"image"
"net/http"
"github.com/go-chi/chi"
"github.com/go-http-utils/etag"
"github.com/pkg/errors"
"go.uber.org/zap"
"github.com/ivanovaleksey/resizer/internal/pkg/cache"
"github.com/ivanovaleksey/resizer/internal/pkg/imagestore"
"github.com/ivanovaleksey/resizer/internal/pkg... |
// Copyright 2020 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 command
import (
"strings"
"github.com/mitchellh/cli"
"github.com/pragkent/aliyun-disk/volume"
)
type GetVolumeNameCommand struct {
Meta
}
func (c *GetVolumeNameCommand) Run(args []string) int {
fs := c.Meta.FlagSet("get_volume_name")
if err := fs.Parse(args); err != nil {
return cli.RunResultHelp
... |
// 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.
package arc
import (
"context"
"fmt"
"os"
"path/filepath"
"strconv"
"time"
"github.com/golang/protobuf/ptypes/empty"
"chromiumos/tast/common/perf"
"chromiumos/tas... |
package hud
import (
"context"
"fmt"
"os"
"runtime"
"runtime/pprof"
"sync"
"time"
"github.com/gdamore/tcell"
"github.com/pkg/errors"
"github.com/tilt-dev/tilt/internal/analytics"
"github.com/tilt-dev/tilt/internal/hud/view"
"github.com/tilt-dev/tilt/internal/openurl"
"github.com/tilt-dev/tilt/internal/o... |
package templates
import(
"fmt"
"bytes"
"text/template"
"io/ioutil"
"encoding/json"
"gopkg.in/yaml.v2"
"github.com/devandrewgeorge/config-generator/internal/pkg/errors"
)
func New(name string, data interface{}) (*Template, error) {
template := &Template{name: name}
switch data.(typ... |
package sizeof
import (
"testing"
)
type (
testGood struct {
ID string
Val int32
Val1 int32
Val2 int16
test1 uint16
test2 uint16
test bool
}
testBad struct {
test bool
test1 uint16
test2 uint16
Val1 int32
Val2 int16
ID string
Val int32
}
test1 struct {
testGood
... |
package bitcoin
import (
. "ftnox.com/common"
"ftnox.com/db"
"time"
"strings"
"errors"
"database/sql"
)
//////////// MPK
//////////// MPK
type MPK struct {
Id int64 `json:"id" db:"id,autoinc"`
PubKey string `json:"pubkey" db:"pubkey"`
Chain string `json:"chain" ... |
// 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 vendorutils contains utils to fetch OEM info.
package vendorutils
import (
"context"
"os"
"strings"
"chromiumos/tast/errors"
"chromiumos/tast/local/crosconf... |
package main
import (
"context"
"log"
"time"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
pb "github.com/willdot/grpccontext/server/proto"
)
const (
address = "localhost:50051"
)
func main() {
// Set up a connection to the server.
conn, err := grpc.Dial(address, grpc.WithInsecure(), grpc.Wit... |
package services
import (
"database/sql"
"io/ioutil"
"os"
"strings"
"github.com/gocarina/gocsv"
)
const (
allEntries = "SELCET entryid, firstname, lastname, email, phone FROM entries;"
entryByID = "SELECT entryid, firstname, lastname, email, phone FROM entries WHERE entryid=%1;"
createEntry ... |
// Copyright 2018 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 products
import (
"distribution-bridge/env"
"distribution-bridge/http"
"distribution-bridge/logger"
"encoding/json"
"errors"
"fmt"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"time"
)
// Sync products from seller account to buyer account.
func SyncProducts() {
page := 0
... |
package main
import (
"fmt"
)
var tabla [10]int
func main() {
tabla[1] = 1
tabla[5] = 15
var tabla2 = [10]int{1, 2, 3, 4, 6, 7, 8, 9, 10, 11}
tabla3 := [10]int{1, 2, 3, 4, 6, 7, 8, 9, 10, 11}
fmt.Println(tabla2)
fmt.Println(tabla3)
//manera de recorrer una tabla 'len' es para saber el tamaño del array
fo... |
package join
import (
"crypto/rand"
"encoding/binary"
"encoding/json"
"fmt"
"time"
"github.com/jmoiron/sqlx"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/brocaar/loraserver/api/gw"
"github.com/brocaar/loraserver/internal/common"
"github.com/brocaar/loraserver/internal/node"
"githu... |
package data
import (
"github.com/kiali/kiali/kubernetes"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func CreateExternalServiceEntry() kubernetes.IstioObject {
return (&kubernetes.GenericIstioObject{
ObjectMeta: meta_v1.ObjectMeta{
Name: "external-svc-wikipedia",
Namespace: "wikipedia",
},
S... |
package main
import (
"flag"
"log"
artiefact "github.com/hirokazu/artiefact-backend"
)
func main() {
flag.Parse()
configFile := flag.Args()
if len(configFile) == 1 {
artiefact.Serve(configFile[0])
} else {
log.Fatal("configuration file is not specified")
}
}
|
// date: 2019-03-15
package cache
import (
"github.com/Jarvens/Exchange-Agent/itf"
"log"
)
func New(typ string) itf.Cache {
var c itf.Cache
if typ == "inMemory" {
c = newInMemoryCache()
}
if c == nil {
panic("未知缓存类型:" + typ)
}
log.Println(typ, "缓存对象实例化失败")
return c
}
|
package gormzap
import (
"go.uber.org/zap"
)
// New create logger object for *gorm.DB from *zap.Logger
func New(zap *zap.Logger) *Logger {
return &Logger{
zap: zap,
}
}
// Logger is an alternative implementation of *gorm.Logger
type Logger struct {
zap *zap.Logger
}
// Print passes arguments to Println
func (... |
package deoxysii
// sliceForAppend extends the capacity of `in` by `n` octets, returning the
// potentially new slice and the appended portion.
//
// This routine is cribbed from the Go standard library and `x/crypto`.
func sliceForAppend(in []byte, n int) (head, tail []byte) {
if total := len(in) + n; cap(in) >= tot... |
package testsupport
import (
"strings"
"github.com/bytesparadise/libasciidoc/pkg/configuration"
"github.com/bytesparadise/libasciidoc/pkg/parser"
"github.com/bytesparadise/libasciidoc/pkg/types"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)
// ParseDocument parses the actual value into a Document... |
package fakes
import (
"time"
"github.com/go-redis/redis"
)
type FakeRClient struct {
getCalledWithKey string
setCalledWithKey string
setCalledWithValue interface{}
users map[string]interface{}
err error
}
func NewFakeRClient() *FakeRClient {
return &FakeRClient{
users: mak... |
package msgpack
import (
"reflect"
"testing"
impl "gopkg.in/vmihailenco/msgpack.v2"
)
func TestMarshaler(t *testing.T) {
type Example struct {
Field1 string `json:"field_1"`
Field2 int `json:"field_2"`
}
example := &Example{
Field1: "field1",
Field2: 128,
}
codec := Codec()
marshal := codec.Mar... |
package anchorpath_test
import (
"testing"
"github.com/stretchr/testify/assert"
anchorpath "github.com/wetware/ww/pkg/util/anchor/path"
)
func TestParts(t *testing.T) {
t.Parallel()
testCases := []struct {
desc, path string
expected []string
}{{
desc: "empty",
path: "",
expected: []string... |
package enums
import (
"bytes"
"encoding"
"errors"
github_com_eden_framework_enumeration "github.com/eden-framework/enumeration"
)
var InvalidRobotType = errors.New("invalid RobotType")
func init() {
github_com_eden_framework_enumeration.RegisterEnums("RobotType", map[string]string{
"SINGLECOPTER": "SINGLEC... |
package sensorsanalytics
import "errors"
var ErrIllegalDataException = errors.New("在发送的数据格式有误时,SDK会抛出此异常,用户应当捕获并处理。")
var ErrNetworkException = errors.New("在因为网络或者不可预知的问题导致数据无法发送时,SDK会抛出此异常,用户应当捕获并处理。")
var ErrDebugException = errors.New("Debug模式专用的异常")
|
package cli
import (
"context"
"sigs.k8s.io/controller-runtime/pkg/client"
"github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1"
)
func newClient(ctx context.Context) (client.Client, error) {
getter, err := wireClientGetter(ctx)
if err != nil {
return nil, err
}
cfg, err := getter.ToRESTConfig()
if err != ni... |
package configuration
var ChatWithMeToken string
var ChatWithMeExtensionUrl string
var MatterMostHost string
var MatterMostAdminUsername string
var MatterMostAdminPassword string
var ChatWithMeTriggerWords []string
var ChatWithMeTriggerWordsEphemeral []string
|
//还需要添加端口
package main1
import (
"flag"
"fmt"
"github.com/PuerkitoBio/goquery"
"github.com/exc/excelize"
"io/ioutil"
"regexp"
"strings"
"os"
)
var dir string
var output string
func main (){
flag.StringVar(&dir,"p",".","报告路径")
flag.StringVar(&output,"o","output.xlsx","结果保存文件")
flag.Parse()
wirte(output)
r... |
/**
* Copyright (c) 2018-present, MultiVAC Foundation.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// Copyright (c) 2013-2014 The btcsuite developers
// Use of this source code is governed by an ISC
// license that can be found i... |
package auth
import (
"context"
fbauth "firebase.google.com/go/auth"
"log"
"server/domain/service"
)
type AuthService interface {
Verify(string) (uid string, err error)
}
type authService struct {
Client fbauth.Client
}
func NewAuthService(client fbauth.Client) service.AuthService {
authService := authServic... |
package main
import (
"testing"
)
func BenchmarkFibV1(b *testing.B) {
// run the Fib function b.N times
k := make(map[int]int)
k[0] = 0
k[1] = 1
for n := 0; n < b.N; n++ {
Fib(5, k)
}
}
|
// Copyright 2020 The VectorSQL Authors.
//
// Code is licensed under Apache License, Version 2.0.
package transforms
import (
"time"
"datablocks"
"planners"
"processors"
"sessions"
)
type OrderByTransform struct {
ctx *TransformContext
plan *planners.OrderByPlan
progressValues sessions... |
package models
import "errors"
var ErrNotFound = errors.New("Requested item is not found!")
var ErrMarshalling = errors.New("Request body could not be marshalled")
var ErrInsert = errors.New("Insert operation failed")
var ErrQuery = errors.New("Error during querying")
|
package blob
// STARTIMPORT, OMIT
import (
"context" // OMIT
"io" // OMIT
"log" // OMIT
//import other packages
"cloud.google.com/go/storage"
)
// STOPIMPORT, OMIT
// STARTGCS, OMIT
type gcs struct {
client *storage.Client
bucket string
object string
}
func (g gcs) Writer() io.WriteCloser {
// gc... |
package main
func main() {
}
func (n *node) find() *node {
if n.parent != n {
n.parent = n.parent.find()
}
return n.parent
}
func (n *node) union(m *node) *node {
nRoot := n.find()
mRoot := m.find()
root := nRoot
if nRoot.rank < mRoot.rank {
nRoot.parent = mRoot
root = mRoot
} else if mRoot.rank < nRo... |
package main
import (
"fmt"
)
func main() {
fmt.Println(superPow(2, []int{1, 1}))
}
const MOD = 1337
// 程式的想法
// 例如:a^123 = ((a^1)^10 * (a^2))^10 * a^3
func superPow(a int, b []int) int {
a %= MOD
if a == 0 {
return 0
}
result := powMod(a, b[0])
for i := 1; i < len(b); i++ {
// 每次都會把前面的結果"十次方",再乘上新數字
... |
package utils
import (
"fmt"
"os"
toml "github.com/pelletier/go-toml"
)
var (
// for app config
APP_Address string
// for db config
DB_Driver, DB_Connect string
// for auth config
Auth_Username, Auth_Password, Auth_Secret string
)
func InitConf(confPath string) {
//Check config file
if _, err := os.Sta... |
package utils
import (
"fmt"
"net"
)
// FindIPAddress - this will find the address associated with an adapter
func FindIPAddress(addrName string) (string, string, error) {
var address string
list, err := net.Interfaces()
if err != nil {
return "", "", err
}
for _, iface := range list {
addrs, err := iface... |
// Copyright 2019 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package crash
import (
"context"
"io/ioutil"
"strings"
"time"
"chromiumos/tast/common/testexec"
"chromiumos/tast/ctxutil"
"chromiumos/tast/local/crash"
"chromiumos/... |
/**
固定长度的有序数组,动态增删改
*/
package array
type FixedOrderArray struct {
elements []int
length int
capacity int
}
func NewFixedOrderArray(cnt int) *FixedOrderArray {
return &FixedOrderArray{
elements: make([]int, cnt),
capacity: cnt,
}
}
func (foa *FixedOrderArray) add(x int) {
}
func (foa *FixedOrderArray) de... |
package common
import (
"shared/utility/coordinate"
"testing"
)
func TestArea_MergePiece(t *testing.T) {
area := NewArea()
area.AppendPiece(1, Piece{StartY: 1, EndY: 3})
area.AppendPiece(1, Piece{StartY: 4, EndY: 8})
area.AppendPiece(1, Piece{StartY: -1, EndY: 11})
area.AppendPiece(1, Piece{StartY: 2, EndY: 1... |
package abi
import (
"errors"
"fmt"
"github.com/hyperledger/burrow/execution/evm/abi"
)
type ABI struct {
spec *abi.Spec
}
func LoadFile(fpath string) (*ABI, error) {
spec, err := abi.LoadPath(fpath)
if err != nil {
return nil, err
}
return newABI(spec), nil
}
func New(buf []byte) (*ABI, error) {
spec, ... |
// Copyright 2020 The Moov Authors
// Use of this source code is governed by an Apache License
// license that can be found in the LICENSE file.
package wire
// RemittanceData is remittance data
type RemittanceData struct {
// Name
Name string `json:"name,omitempty"`
// DateBirthPlace
DateBirthPlace string `json:... |
// 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.
package extractor
import (
"context"
"fmt"
"io"
"math/rand"
"strings"
"sync"
"sync/atomic"
"time"... |
package main
import (
"fmt"
"sort"
"sync"
)
type Number interface {
int | float64
}
func swap[T Number](a []T) {
for i := 0; i < len(a)-1; i = i + 2 {
a[i], a[i+1] = a[i+1], a[i]
}
}
func fact(v int) int {
var r int = 1
for i := v; i > 0; i-- {
r = r * i
}
return r
}
func sortMap(v map[int]string) {
... |
// 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 server
import (
"context"
"crypto/tls"
"fmt"
"net"
"net/http"
"path/filepath"
"github.com/emicklei/go-restful"
"github.com/rancher/dynamiclistener"
"github.com/rancher/dynamiclistener/factory"
"github.com/rancher/dynamiclistener/storage/file"
"github.com/rancher/dynamiclistener/storage/memory"
"k8... |
package main
import (
"encoding/json"
"log"
db "github.com/jerrydevin96/lifo-queue/database"
)
func pushHandler(data string) string {
response := ``
log.Println("Pushing item into queue")
var JSONValue map[string]string
responseJSON := make(map[string]string)
json.Unmarshal([]byte(data), &JSONValue)
log.Pri... |
package rfc7807
import (
"bytes"
"encoding/json"
"fmt"
"net/url"
"reflect"
"strings"
)
// DTO error data transfer object is made in an effort to standardize REST API error handling,
// the IETF devised RFC 7807, which creates a generalized error-handling schema.
// https://www.rfc-editor.org/rfc/rfc7807
//
// E... |
/*
Copyright 2020 Docker Compose CLI 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 a... |
package funnystring
// https://www.hackerrank.com/challenges/funny-string
func absDiff(ar, br rune) uint16 {
a := uint16(ar)
b := uint16(br)
if a < b {
return b - a
}
return a - b
}
// FunnyString - implements the solution to the problem
func FunnyString(s string) string {
sr := []rune(s)
n := len(s)
for i... |
package config
import "testing"
func TestInitConfig(t *testing.T) {
InitConfig("/../config/config.yml")
t.Log(GetService())
}
|
package main
import (
"database/sql"
"fmt"
_ "github.com/lib/pq"
)
const (
user = "postgres"
password = "pass"
host = "prix.plus"
dbname = "admin"
sslmode = "disable"
)
func InitDB() (*sql.DB, error) {
dbinfo := fmt.Sprintf("user=%s password=%s host=%s dbname=%s sslmode=%s",
user, password, ho... |
package main
import (
"log"
"math/rand"
"sync"
"time"
)
//STARTMAIN, OMIT
func main() {
r := referree{}
p1 := newPlayer("ping")
p2 := newPlayer("pong")
g := newGame(p1, p2) // HL3
r.Start(g) //start on main goroutine // HL3
}
//STOPMAIN, OMIT
type ball struct {
hits int
lastPlayer strin... |
// Copyright 2021 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 torproxy
import (
"crypto/rand"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"log"
"net"
"net/http"
"net/url"
"strings"
"time"
"github.com/caddyserver/certmagic"
"github.com/tdex-network/tor-proxy/pkg/registry"
"golang.org/x/net/http2"
"golang.org/x/net/proxy"
)
type TorClient struct {
Host st... |
package main
import (
"fmt"
"os"
"strconv"
)
func fbzrecur(number int) {
if number < 3 {
os.Exit(0)
}
if number%15 == 0 {
fmt.Println("Number:", number, "is fizzbuzz")
} else if number%5 == 0 {
fmt.Println("Number:", number, "is buzz")
} else if number%3 == 0 {
fmt.Println("Number:", number, "is fizz"... |
// Copyright 2015 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 cmd
import (
"auth/internal/config"
"database/sql"
"errors"
"fmt"
_ "github.com/lib/pq"
migrate "github.com/rubenv/sql-migrate"
"github.com/spf13/cobra"
"go.uber.org/zap"
)
var (
migrateCmd = &cobra.Command{
Use: "migrate [sub]",
Short: "migration db auth",
Run: func(cmd *cobra.Command, arg... |
package fakes
import "github.com/kkallday/tracker-cli/trackerapi"
type Logger struct {
LogCall struct {
CallCount int
Receives struct {
Message string
}
}
LogStoriesCall struct {
CallCount int
Receives struct {
Stories []trackerapi.Story
}
}
}
func (l *Logger) Log(message string) {
l.LogCall... |
package leetcode
import (
"sort"
"strings"
)
func isAnagram(s string, t string) bool {
if len(s) != len(t) {
return false
}
s1:=strings.Split(s,"")
t1:=strings.Split(t,"")
sort.Strings(s1)
sort.Strings(t1)
s=strings.Join(s1,"")
t=strings.Join(t1,"")
return strings.Compare(s, t) == 0
}
|
package contextkeys
type key int
const (
// KeyAPIVersion define the key to the api version value in the context
KeyAPIVersion key = 1
)
|
package version
// Version is the git version that produced this binary.
var Version string
// When is the datestamp that produced this binary.
var When string
|
package utils
// === IMPORTS ===
import (
"regexp"
)
// === PUBLIC METHODS ===
// IsValidDomain checks if a domain has a valid format
func IsValidDomain(domain string) bool {
pattern := `^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$`
expression := regexp.MustCompile(pattern)
retur... |
package goderp
import (
"fmt"
"github.com/BurntSushi/toml"
"os"
"reflect"
"strconv"
"strings"
"unicode/utf8"
)
type Info struct {
descr string
group string
def interface{}
}
type Config struct {
Records map[string]interface{}
Descriptions map[string]Info
enableEnvVars bool
}
func New() *Config... |
package model
import (
"github.com/holywolfchan/yuncang/db"
"github.com/holywolfchan/yuncang/utils/logs"
)
var dropAndCreate bool = false
var DB = db.Engine
var TableStruct = []interface{}{
new(User),
new(Role),
new(Domain),
new(MaterialList),
new(MaterialLogin),
new(MaterialLogout),
new(MaterialOrder),
new... |
package model
import (
"time"
"gorm.io/gorm"
)
const CtxKeyAuthorizedUser = "ckau"
const CtxKeyViewPasswordVerified = "ckvpv"
const CacheKeyOauth2State = "p:a:state"
type Common struct {
ID uint64 `gorm:"primaryKey"`
CreatedAt time.Time `gorm:"index;<-:create"`
UpdatedAt time.Time `gor... |
package main
import (
"fmt"
"log"
"os"
"runtime"
"time"
"gopkg.in/alecthomas/kingpin.v1"
)
const (
defaultBufsizeTCP = 128000 // 128K
defaultBufsizeUDP = 8000 // 8K
)
var (
bufsize int
unit *Unit
makeStopTimer func() <-chan time.Time
makeIntervalTimer func() <-chan time.Time... |
package main
import (
"time"
"os"
"fmt"
"context"
"os/signal"
"net/http"
"encoding/json"
"github.com/cap-diego/dfa-minimization-algorithm"
)
func enableCors(w *http.ResponseWriter) {
(*w).Header().Set("Access-Control-Allow-Origin", "*")
}
func minimizeAutomata(w http.ResponseWriter, r *http.Request) {
enabl... |
package main
import (
"bufio"
"fmt"
"log"
"os"
)
var (
code map[rune]int
tile map[int]rune
)
func init() {
code = map[rune]int{' ': 0, '\\': 0, '/': 0, 'X': 0, '*': 1, '#': 2, 'o': 3}
tile = map[int]rune{0: ' ', 1: '*', 2: '#', 3: 'o'}
}
type ray struct {
x int
y int
dir int
ttl int
}
func (a ray) ... |
package v1
import (
"fmt"
"github.com/gin-gonic/gin"
"go.rock.com/rock-platform/rock/server/clients/k8s"
"go.rock.com/rock-platform/rock/server/clients/license"
"go.rock.com/rock-platform/rock/server/database/api"
"go.rock.com/rock-platform/rock/server/utils"
"io/ioutil"
"net/http"
"os"
)
const (
LicenseMod... |
package client
import (
"net/http"
"github.com/farzadrastegar/simple-cab/gateway"
"github.com/spf13/viper"
)
type RequestService interface {
ExecuteRequest(req *http.Request) (*http.Response, error)
}
// Client represents a client to connect to the HTTP server.
type Client struct {
cabService CabService
Han... |
package gitreceive
import (
"fmt"
)
const (
slugTGZName = "slug.tgz"
// CacheKeyPattern is the template for location cache dirs.
CacheKeyPattern = "home/%s/cache"
// GitKeyPattern is the template for storing git key files.
GitKeyPattern = "home/%s:git-%s"
)
// SlugBuilderInfo contains all of the object storage... |
package autotag
import (
"fmt"
"testing"
"time"
"github.com/gogits/git-module"
)
func newRepo(t *testing.T, preName, preLayout string, prefix bool) GitRepo {
path := createTestRepo(t)
repo, err := git.OpenRepository(path)
checkFatal(t, err)
seedTestRepoPrefixToggle(t, repo, prefix)
r, err := NewRepo(GitRe... |
package backend
import "github.com/anabiozz/yotunheim/backend/common/datastore"
const (
// Counter ...
Counter = "counter"
// Gauge ...
Gauge
// Untyped ...
Untyped
// Summary ...
Summary
// Histogram ...
Histogram = "histogram"
// Table ...
Table = "table"
)
// Accumulator ...
type Accumulator interface... |
package main
import "fmt"
// Complete the alternatingCharacters function below.
func alternatingCharacters(s string) int32 {
count := int32(0)
last := s[0]
for i := 1; i < len(s); i++ {
if last == s[i] {
count++
}
last = s[i]
}
return count
}
func main() {
var input string
var output int32
input = ... |
package model
type OrderItem struct {
HotelId int64 `json:"hotel,omitempty"`
OrderItemId int64 `json:"id,omitempty"`
OrderId int `json:"pedido,omitempty"`
ProductId int `json:"id_produto,omitempty"`
Product Product `json:"produto,omitempty"`
UserId ... |
// Copyright (c) Mainflux
// SPDX-License-Identifier: Apache-2.0
package http
import "github.com/mainflux/mainflux/things"
type identifyReq struct {
Token string `json:"token"`
}
func (req identifyReq) validate() error {
if req.Token == "" {
return things.ErrUnauthorizedAccess
}
return nil
}
type canAccessB... |
package concepts
import (
"encoding/json"
"errors"
"fmt"
"net/http"
fthealth "github.com/Financial-Times/go-fthealth/v1_1"
)
const conceptSearchQueryParam = "ids"
var (
// ErrNoConceptsToSearch indicates the provided uuids array was empty
ErrNoConceptsToSearch = errors.New("no concept ids to search for")
//... |
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
package patch
import (
"reflect"
"testing"
"github.com/DataDog/datad... |
// 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.
package util
import (
"bufio"
"context"
"encoding/json"
"io/ioutil"
"math"
"os"
"regexp"
"strconv"
"strings"
"chromiumos/tast/common/testexec"
"chromiumos/tast/e... |
package templates
import (
"text/template"
)
func Parse(t string) (*template.Template, error) {
return template.New("").Funcs(numericFuncs()).Funcs(stringFuncs()).Parse(t)
}
|
package odoo
import (
"fmt"
)
// CalendarEvent represents calendar.event model.
type CalendarEvent struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
Active *Bool `xmlrpc:"active,omptempty"`
ActivityIds *Relation `xmlrpc:"activity_ids,omptempty"`
... |
// Copyright 2017 The Cockroach Authors.
//
// Licensed as a CockroachDB Enterprise file under the Cockroach Community
// License (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// https://github.com/cockroachdb/cockroach/blob/master/li... |
package v1alpha1
import (
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"code.cloudfoundry.org/quarks-operator/pkg/kube/apis"
)
// This file is safe to edit
// It's used as input for the Kube code generator
// Run "make generate" after modifying this file
// ReferenceType lists all the types of Reference ... |
package solutions
func longestValidParentheses(s string) int {
var stack = make([]int, len(s) + 1)
currentStart := -1
currentIndex := 0
result := 0
for i := 0; i < len(s); i++ {
if s[i] == '(' {
stack[currentIndex] = currentStart
currentStart = i
current... |
package dinosql
import (
"fmt"
"io/ioutil"
"path/filepath"
"sort"
"strconv"
"strings"
"github.com/davecgh/go-spew/spew"
"github.com/kyleconroy/dinosql/internal/catalog"
core "github.com/kyleconroy/dinosql/internal/pg"
"github.com/kyleconroy/dinosql/internal/postgres"
pg "github.com/lfittl/pg_query_go"
no... |
package main
import (
"fmt"
"log"
"net/http"
"github.com/gorilla/websocket"
"github.com/sajallimbu/main/pubsub"
uuid "github.com/satori/go.uuid"
)
var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
}
// autoID ... returns a UUID
func autoID() string {
return uuid.Must(uuid.New... |
// cache.go
//
// Author: blinklv <blinklv@icloud.com>
// Create Time: 2018-08-22
// Maintainer: blinklv <blinklv@icloud.com>
// Last Change: 2018-10-15
// A concurrency-safe cache for applications running on a single machine. It supports
// set operation with expiration. Elements are not stored in a single pool (map)... |
package client
import (
"encoding/json"
"io/ioutil"
"net/http"
"github.com/go-openwrks/openwrks/response"
)
func TransformResponse(src *http.Response, dst interface{}) error {
defer src.Body.Close()
d, err := ioutil.ReadAll(src.Body)
if err != nil {
return err
}
// If the status code is that of an error... |
package lantern_cache
import (
"bytes"
"fmt"
"sync"
"sync/atomic"
"time"
)
type bucketConfig struct {
maxCapacity uint64
initCapacity uint64
chunkAlloc *chunkAllocator
statistics *Stats
}
type bucket struct {
mutex sync.RWMutex
m map[uint64]uint64
offset uint64
loop uint32
... |
package geoip
import (
"context"
"github.com/alecthomas/kingpin"
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/cli/root"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/ooni"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/output"
)
func init() {
cmd := root.Command("geo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.