text stringlengths 11 4.05M |
|---|
/*
Copyright 2020 Huawei 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, software
dis... |
package main
//求 1+2+...+n ,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。
func sumNums(n int) int {
result := 0
var sum func(x int) bool
sum = func(x int) bool {
result += x
return x > 0 && sum(x-1)
}
sum(n)
return result
}
func main() {
println(sumNums(6))
}
|
package css_test
import (
"testing"
sitter "github.com/kiteco/go-tree-sitter"
"github.com/kiteco/go-tree-sitter/css"
"github.com/stretchr/testify/assert"
)
func TestGrammar(t *testing.T) {
assert := assert.New(t)
parser := sitter.NewParser()
parser.SetLanguage(css.GetLanguage())
sourceCode := []byte(`
div ... |
// 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 policy
import (
"context"
"time"
"chromiumos/tast/common/tape"
"chromiumos/tast/ctxutil"
"chromiumos/tast/remote/policyutil"
"chromiumos/tast/rpc"
"chromiumo... |
package main
import (
"testing"
)
func TestCode(t *testing.T) {
var tests = []struct {
houseStart int
houseEnd int
appleLoc int
orangeLoc int
apples []int
oranges []int
appleOut int
orangeOut int
}{
{
houseStart: 7,
houseEnd: 11,
appleLoc: 5,
orangeLoc: 15,
appl... |
package core
type Config struct {
VmessUUID string
VmessPort uint
ShadowsocksPassword string
ShadowsocksPort uint
VmessWsPort uint
VmessWsUUID string
VmessWsPath string
}
type Inbound struct {
Port int `json:"port"`
Protocol string `json:"protocol"`
Set... |
// +build ignore
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// START OMIT
package runtime
type g struct {
stack stack // offset known to runtime/cgo
stackguard0 uintptr // offset known to lib... |
package cmd
import (
"fmt"
"github.com/georgevella/helmtmpl/config"
"github.com/spf13/cobra"
"strings"
)
var environment string
func init() {
rootCmd.AddCommand(renderCmd)
rootCmd.Flags().StringVarP(&environment, "environment", "e", "", "Name of environment to render")
}
var renderCmd = &cobra.Command{
Use... |
package users
import (
"github.com/graphql-go/graphql"
"github.com/juliotorresmoreno/unravel-server/crud"
"github.com/juliotorresmoreno/unravel-server/db"
"github.com/juliotorresmoreno/unravel-server/models"
)
var tipos = map[string]graphql.Type{
"id": graphql.Int,
"nombres": graphql.String,
"apellido... |
package common
import (
"bytes"
"context"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestAPIError(t *testing.T) {
ae := NotFound("ClusterNotReadyException: test")
ae.Resource = "c"
asse... |
//
// Package - transpiled by c4go
//
// If you have found any issues, please raise an issue at:
// https://github.com/Konstantin8105/c4go/
//
package pkg
// package_import_t - transpiled function from /home/istvan/packages/downloaded/cbuild/package/import.c:15
type package_import_t struct {
alias []byte
filen... |
package main
import "fmt"
func fbn(n int) []uint64 {
var arr = make([]uint64, n)
arr[0] = 1
arr[1] = 1
for i := 2; i < n; i++ {
arr[i] = arr[i-1] + arr[i-2]
}
return arr
}
func main() {
s := fbn(10)
fmt.Println(s)
}
|
package api
import (
// "log"
"github.com/J-HowHuang/Ramen-Live/backend/pkg/loc"
)
func HandleGetNearbyRegions(message map[string]interface{}) map[string]interface{} {
location := message["user_location"].(map[string]interface{})
lat := location["lat"].(float64)
lon := location["lon"].(float64)
... |
// +build !js
package math4g_test
import (
"fmt"
"github.com/shibukawa/math4g"
"math"
)
func ExampleTranslateMatrix() {
// move 10, 20
translate := math4g.TranslateMat32(10, 20)
x, y := translate.TransformPoint(5, 5)
fmt.Println(x, y)
// Output: 15 25
}
func ExampleRotateMatrix() {
// rotate 90 degree
rot... |
package nfs
import (
"github.com/storageos/cluster-operator/pkg/util"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)
const (
// DataVolName is the NFS data volume name.
DataVolName = "nfs-data"
)
func (d *Deployment... |
package gosi
import (
"encoding/json"
"math"
"github.com/shirou/gopsutil/v3/disk"
"github.com/inhies/go-bytesize"
)
type DiskStat struct {
Name string `json:"name"`
Total string `json:"total"`
Free string `json:"free"`
Used string `json:"used"`
UsedPercent uint `json:"usedPerce... |
package main
import (
"bufio"
"fmt"
"log"
"net/http"
"os"
"github.com/go-icap/icap"
)
var (
ISTag = "\"GOLANG\""
lines []string
)
func readLines(path string) ([]string, error) {
file, err := os.Open(path)
if err != nil {
return nil, err
}
defer file.Close()
scanner := bufio.NewScanner(file)
for sca... |
package main
import(
"unicode"
)
func removeZeros(s string) string{
PIdx :=0
ret := ""
for ; PIdx<len(s); PIdx++{
if s[PIdx] == '.'{
break
}
}
start := 0
end := len(s) - 1
for ; start < PIdx-1; start++{
if s[start] != '0'{
break
}
}
for ; end > PIdx; end--{
if s[end] != '0'{
break
}
... |
package v1
import (
"errors"
"fmt"
"net/http"
"net/http/httptest"
"testing"
"time"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
mockConfig "github.com/traPtitech/trap-collection-server/src/config/mock"
"github.com/traPtitech/tr... |
//go:build s390x
// +build s390x
package arch
const Arch = ArchS390
const Flavor = FlavorDefault
|
package problem14
import (
"exercises/aoc2020/common"
"fmt"
"math"
"regexp"
"strconv"
)
func Solve() (uint64, uint64, error) {
return SolveBoth("./problem14/input.txt")
}
func SolveBoth(inputFile string) (uint64, uint64, error) {
instructions, err := common.ParseFile(inputFile, parseLine)
if err != nil {
r... |
package views
import (
"strings"
"net/http"
"text/template"
)
type TagsInstallData struct {
ClientSecret string
RepoOpts string
Packages string
}
func ServeTags(w http.ResponseWriter, r *http.Request, baseurl string, secret string, logo string, directory string, foldersMap map[string]string, ta... |
package main
import (
"fmt"
"bufio"
"os"
"strings"
)
func main() {
reader := bufio.NewReader(os.Stdin)
s, _ := reader.ReadString('\n')
items_str, _ := reader.ReadString('\n')
items := strings.Split(items_str, " ")
fmt.Printf(s)
fmt.Printf("%v", items)
} |
package internal
import (
"bytes"
"errors"
"io"
"os"
"strings"
"github.com/jedib0t/go-pretty/table"
"gopkg.in/yaml.v2"
)
// Signatures represents the plugins/rules from the
// .yaml configuration file. It's the root of a config
// file.
type Signatures struct {
Plugins []Plugin `yaml:"plugins"`
}
// Plugin ... |
package main
import (
"context"
"flag"
"fmt"
"net/http"
"os"
"os/signal"
"time"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
chiadapter "github.com/awslabs/aws-lambda-go-api-proxy/chi"
log "github.com/sirupsen/logrus"
"github.com/ramrodo/tech-assessment-loan-startup/router"... |
package admin
import (
"time"
"github.com/astaxie/beego/orm"
)
type Customer struct {
Id int `orm:"column(id);auto" description:"主键"`
Uid string `orm:"column(uid);size(50)" description:"用户ID"`
Username string `orm:"column(username);size(255);null" description:"用户名"`
Password str... |
// Copyright 2018 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 client
import (
"fmt"
"net/url"
"strings"
"github.com/hyperhq/hyper/engine"
"github.com/hyperhq/runv/hypervisor/types"
gflag "github.com/jessevdk/go-flags"
)
func (cli *HyperClient) HyperCmdRmi(args ...string) error {
var opts struct {
Noprune bool `long:"no-prune" default:"false" default-mask:"-" ... |
package util
import (
"math/rand"
"runtime"
"time"
)
func Platform() (string, string) {
return runtime.GOOS, runtime.GOARCH
}
func SetSeed() {
rand.Seed(time.Now().UnixNano())
}
func Random(n int) (res int) {
res = rand.Intn(n)
return
}
func Sum() func(int) int {
var sum int = 0
... |
package bench
import "testing"
func benchmarkCumulativeWithMemo(b *testing.B, day int) {
for ii := 0; ii < b.N; ii++ {
cumulativeWithMemo(day)
}
}
func benchmarkCumulativeWithoutMemo(b *testing.B, day int) {
for ii := 0; ii < b.N; ii++ {
cumulativeWithoutMemo(day)
}
}
func BenchmarkCumulative10(b *testing.B... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"reflect"
"strings"
"time"
"github.com/gocql/gocql"
)
var session *gocql.Session
func executeQuery1(query string) ([]map[string]interface{}, error) {
return nil, nil
}
func createSession(clusterIPs []string, keyspace string) (*gocql.Session, er... |
package scanner
// SendAnalysisData sends analysis data if the user opts in
func (scanner *Scanner) SendAnalysisData(data map[string]interface{}) {
scanner.analysisDataSender(data)
}
|
package main
type A struct {
a int
}
func (aa *A) get() int {
return aa.a
}
func (aa *A) get2() int {
return aa.a
}
func main() {
aa := A{1}
for i := 1; i < 100; i++ {
tmp := i
go func() {
if tmp < 30 {
aa.get()
} else {
aa.get2()
}
}()
}
}
|
// 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 firewall wraps basic iptables call to control
// filtering of incoming/outgoing traffic.
package firewall
import (
"chromiumos/tast/common/network/firewall"
"ch... |
package main
import (
"fmt"
"net"
"sync"
"time"
. "github.com/miekg/dns"
)
func HelloServer(w ResponseWriter, req *Msg) {
m := new(Msg)
m.SetReply(req)
m.Extra = make([]RR, 1)
m.Extra[0] = &TXT{Hdr: RR_Header{Name: m.Question[0].Name, Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Tx... |
package main
import (
"github.com/xiaotuanyu120/cobra_example/cmd"
)
var Version = "0.1.1"
func main() {
cmd.Version = Version
cmd.Execute()
}
|
// Package ai provides drivers for the computer client.
package ai
|
package main
import (
"fmt"
"sort"
)
func main() {
candidates := []int{1} //{10, 1, 2, 7, 6, 1, 5}
fmt.Println(candidates)
target := 1 //8
results := combinationSum2(candidates, target)
fmt.Println(results)
}
func combinationSum2(candidates []int, target int) [][]int {
sort.Ints(candidates)
results := [][]i... |
package main
import (
"fmt"
)
func main() {
var s1 []int
fmt.Println(s1)
a := [10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
fmt.Println(a)
s2 := a[5:]
fmt.Println(s2)
s3 := make([]int, 10, 100)//类型,填充元素,容量 每次2倍提升
fmt.Println(s3)
fmt.Println(len(s3), cap(s3))
fmt.Println("------------")
s4 :=[]byte{'a','b',... |
package lc
func maxProduct(nums []int) int {
if len(nums) == 1 {
return nums[0]
}
var neg, pos int
max := nums[0]
for i := 0; i < len(nums); i++ {
if nums[i] > 0 {
if pos == 0 && neg == 0 {
pos = nums[i]
continue
}
if pos == 0 {
pos, neg = nums[i], neg*nums[i]
} else {
pos, neg =... |
package config
import (
"github.com/workfoxes/gobase/pkg/config/client"
"github.com/go-chi/chi"
"net/http"
)
var (
conn string
)
type Context struct {
AccountId string
DB *client.Database
BaseDB *client.Database
Cache *client.RedisClient
}
func LoadContext(r *http.Request, userId string) *Cont... |
package prezi
import "time"
const timeFormat = `January _2, 2006`
type Date time.Time
func (ct Date) MarshalBinary() ([]byte, error) {
t := time.Time(ct)
return t.MarshalBinary()
}
func (ct Date) MarshalJSON() ([]byte, error) {
return []byte(`"` + ct.String() + `"`), nil
}
func (ct *Date) UnmarshalBinary(data ... |
package gnr
type Union struct {
Objects []Object
}
func NewUnion(o ...Object) *Union {
return &Union{o}
}
func (u *Union) RayInteraction(r *Ray) []*InteractionResult {
// Check ray interaction with all objects, only return the one closes to the origin
irs := ObjectSlice(u.Objects).AggregateSliceInteractionResult... |
package world
import (
"github.com/galaco/bsp/primitives/leaf"
"github.com/galaco/lambda-client/scene/visibility"
"github.com/galaco/lambda-core/entity"
"github.com/galaco/lambda-core/mesh"
"github.com/galaco/lambda-core/model"
"github.com/go-gl/mathgl/mgl32"
"sync"
)
type World struct {
entity.Base
staticMo... |
package matchers
import (
"errors"
"net/http/httptest"
)
func requireRespRec(actual interface{}) (*httptest.ResponseRecorder, error) {
rr, ok := actual.(*httptest.ResponseRecorder)
if !ok {
return nil, errors.New("actual must be a *httptest.ResponseRecorder")
}
return rr, nil
}
func mustRespSec(actual interf... |
// Package languagecode provides utilities for representing languages in code,
// and handling their serializations and deserializations in a convenient way.
//
// All serializations will result in `LanguageUndefined` if input data is not a
// recognized language code. Some conversions are lossy as not all languages
//... |
package transcoder
import (
"fmt"
"log"
"os"
"os/exec"
"path"
"path/filepath"
"strings"
"sync"
"github.com/fsnotify/fsnotify"
)
var commandTempl = "ffmpeg -i %s -profile:v baseline -level 3.0 -s 640x360 -start_number 0 -hls_time 10 -hls_list_size 0 -f hls %s"
var allowedExts = map[string]bool{
".mp4": true... |
package engine
import (
"container/list"
"errors"
"fmt"
"github.com/denkhaus/tcgl/applog"
"github.com/fsouza/go-dockerclient"
"math"
)
var (
errCircularDependency = errors.New("Manifest error:: circular dependency detected")
)
type ContainerAggregateFunc func(e *list.Element, val interface{}) interface{}
type... |
package buqi
import (
"log"
"net"
)
// Local 本地端
type Local struct {
*Socket
}
// NewLocal 新建一个本地端
func NewLocal(password *Password, listenAddr, remoteAddr *net.TCPAddr) *Local {
return &Local{
Socket: &Socket{
Cipher: NewCipher(password),
ListenAddr: listenAddr,
RemoteAddr: remoteAddr,
},
}
}
... |
package readers
import (
"bufio"
"compress/gzip"
"io"
"os"
)
func ReadFileLines(path string) (chan []byte, error) {
var err error
var file *os.File
if file, err = os.Open(path); err == nil {
return ReadLines(file)
}
return nil, err
}
func ReadGzipLines(path string) (chan []byte, error) {
var err error
v... |
// Copyright © 2018 NAME HERE <EMAIL ADDRESS>
//
// 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 ... |
package chanrpc
import (
"fmt"
"reflect"
)
type Server struct {
functions map[string]interface{}
chanReq chan *Request
}
type Request struct {
f string
args []interface{}
resp bool
chanResp chan *Response
}
type Response struct {
rets []interface{}
err error
}
func NewServer(l int) *Ser... |
package command
import (
"flag"
"os"
"sort"
"testing"
"github.com/mitchellh/cli"
"github.com/stretchr/testify/assert"
)
var (
// default test values
metaTest *Meta
fClientCert string
fClientKey string
fCACert string
fCAPath string
fAddr = "http://127.0.0.1:8200"
fInsecure = false
)
... |
package main
import (
"fmt"
)
func main(){
p := new(int) // p, of type *int, points to an unnamed int variable
fmt.Println(*p) // "0"
*p = 2 // sets the unnamed int to 2
fmt.Println(*p) // "2"
p2 := new(int)
q2 := new(int)
fmt.Println(p2 == q2) // "false"
}
|
package common
import "time"
// for common
const (
EmptyString = ""
PaymentAddressLength = 66
ZeroByte = byte(0x00)
DateOutputFormat = "2006-01-02T15:04:05.999999"
DateInputFormat = "2006-01-02T15:04:05.999999"
NextForceUpdate = "2019-06-15T23:59:00.000000"
)
// for exit code... |
package model
// DecimalHolder defines all graph that should be able to store a decimal value.
type DecimalHolder interface {
AcceptDecimal(val int64) error
}
|
package main
package main
|
package bytedance
import (
"fmt"
"strconv"
)
func Code1020() {
arr := []int{-1, 0, 1, 2, -1, -4}
fmt.Println(threeSum(arr))
}
/**
给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?找出所有满足条件且不重复的三元组。
注意:答案中不可以包含重复的三元组。
例如, 给定数组 nums = [-1, 0, 1, 2, -1, -4],
满足要求的三元组集合为:
[
[-1, 0, 1],
[-1, -1... |
package runtime_test
import (
. "github.com/d11wtq/bijou/runtime"
"github.com/d11wtq/bijou/test"
"testing"
)
func TestBooleanType(t *testing.T) {
if True.Type() != BooleanType {
t.Fatalf(`expected True.Type() == BooleanType, got %s`, True.Type())
}
if False.Type() != BooleanType {
t.Fatalf(`expected False.... |
/*
* Copyright (C) 2018 Pierre Marchand <pierre.m@atelier-cartographique.be>
*
* 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 righ... |
// Copyright (c) 2016-2019 Uber Technologies, 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... |
package repo
import (
"path/filepath"
"github.com/izumin5210/scaffold/domain/scaffold"
"github.com/pkg/errors"
)
func (r *repo) Create(e scaffold.Entry) (bool, bool, error) {
parent := filepath.Dir(e.Path())
parentCreated, err := r.fs.CreateDir(parent)
if err != nil {
return false, parentCreated, errors.Wrap... |
package wxapp
// 秒杀商品表
type SeckillProduct struct {
ComID int64 `json:"com_id"`
ID int64 `json:"id" bson:"id"`
Product string `json:"product" bson:"product"`
Price float64 `json:"price" bson:"price"` // 原价
DiscountPrice float64 `json:"discount_price" bson:"... |
package internal
import (
"framework/cluster"
"gamesvr/game"
"gamesvr/svrconf"
)
type Module struct {
*cluster.Cluster
}
func (m *Module) OnInit() {
m.Cluster = &cluster.Cluster{
MaxMsgLen: svrconf.MaxMsgLen,
AgentChanRPC: game.ChanRPC,
}
}
|
package protocol_handler
import (
"decept-defense/controllers/comm"
"decept-defense/internal/message_client"
"decept-defense/models"
"decept-defense/pkg/app"
"decept-defense/pkg/configs"
"decept-defense/pkg/util"
"encoding/json"
"github.com/astaxie/beego/validation"
"github.com/gin-gonic/gin"
"github.com/unk... |
package typeutils
import (
"reflect"
"testing"
"github.com/stretchr/testify/suite"
)
// These tests confirm the developer's understanding of how Go works.
// More specifically how the Go reflection mechanism works.
var (
a = alpha{Name: "Hubert", Percent: 17.23}
b = bravo{Finished: true, Iteratio... |
/*
Copyright 2015 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 required by applicable law or agreed to in writing, soft... |
package LeetCode
import (
"fmt"
)
func Code516() {
fmt.Println(longestPalindromeSubseq("bbbab"))
}
/**
给定一个字符串s,找到其中最长的回文子序列。可以假设s的最大长度为1000。
示例 1:
输入:
"bbbab"
输出:
4
一个可能的最长回文子序列为 "bbbb"。
示例 2:
输入:
"cbbd"
输出:
2
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/longest-palindromic-subsequence
著作权归领扣网络所有。商业... |
// Copyright 2020 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 array
func removeDuplicates(nums []int) int {
if nums == nil || len(nums) == 0 {
return 0
}
fis := 0
las := 1
for las != len(nums) {
if nums[fis] != nums[las] {
fis++
nums[fis] = nums[las]
}
las++
}
return fis + 1
}
|
package main
import (
"io"
"os"
"sort"
"github.com/yuyamada/atcoder/lib"
)
func main() {
solve(os.Stdin, os.Stdout)
}
func solve(reader io.Reader, writer io.Writer) {
io := lib.NewIo(reader, writer)
defer io.Flush()
w, h, n := io.NextInt(), io.NextInt(), io.NextInt()
x1 := io.NextInts(n)
x2 := io.NextInts... |
package zombie_driver
// DriverID represents a driver identifier.
type DriverID int
// Status represents driver status based on records in database.
type Status struct {
ID DriverID `json:"id"`
Zombie bool `json:"zombie"`
}
// Client creates a connection to the services.
type Client interface {
Connect() ... |
package delete
import (
"encoding/json"
"fmt"
"net/http"
"github.com/ocoscope/face/db"
"github.com/ocoscope/face/utils"
"github.com/ocoscope/face/utils/answer"
)
func User(w http.ResponseWriter, r *http.Request) {
type tbody struct {
CompanyID, UserID, DeleteUserID int64
AccessToken s... |
/*
@Time : 2019/9/16 17:57
@Author : zxr
@File : date
@Software: GoLand
*/
package tools
import (
"fmt"
"time"
)
func GetCurrentUnix() int64 {
var cstSh, _ = time.LoadLocation("Asia/Shanghai") //上海
now := time.Now().In(cstSh)
formStr := fmt.Sprintf("%d-%02d-%02d %02d:%02d:%02d", now.Year(), now.Month(), now.Day(... |
package deltal
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"sync"
"testing"
)
type cryptTest struct {
In, Out, Pass string
Check bool
}
var (
crypting = []cryptTest{
{"encoder.go", "../test/encoder.go.pw.delta", "pw", true},
{"encoder.go", "../test/encoder.go.delta", "", true},
{"encoder.go"... |
package main
import (
"local/crypto-api/auth"
"net/http"
"local/crypto-api/crypto"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
r.POST("/api/login", auth.LoginEndpoint)
cryptoGroup := r.Group("/api/crypto")
cryptoGroup.Use(AuthMidleware())
{
cryptoGroup.GET("/btc", crypto.GetCryptoEndp... |
package main
import (
"bytes"
"encoding/binary"
"io"
"net"
"net/url"
"regexp"
)
func encodeSize(message []byte) []byte {
size := make([]byte, 2)
binary.LittleEndian.PutUint16(size, uint16(len(message)))
return size
}
func uwsgiPack(path, query, host, remoteAddr string, modifier1 int) []byte {
if path == ""... |
package copy
import (
"bytes"
"encoding/json"
"fmt"
"os"
"os/exec"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var environmentCMD = &cobra.Command{
Use: "environment",
Short: "Copy env variables configmap for a microservice in one environment to another environment",
... |
package app
import (
"database/sql"
"fmt"
"log"
"strings"
"github.com/gin-gonic/gin"
"github.com/jmoiron/sqlx"
"github.com/mercedtime/api/db/models"
"github.com/mercedtime/api/users"
)
// RegisterRoutes will setup all the app routes
func (a *App) RegisterRoutes(g *gin.RouterGroup) {
g.POST("/user", a.PostUs... |
package game
import (
"reflect"
"testing"
)
var gmsLegal = []Game{
Game{
3,
Players{'A', 'B', 'C'},
History{},
},
Game{
10,
Players{'Ä', 'B', '😛'},
History{
Move{'Ä', 0, 0},
},
},
Game{
5,
Players{'1', '2', '3'},
History{
Move{'1', 0, 0},
Move{'2', 2, 0},
Move{'3', 0, 1},
Mo... |
package router
import (
"editorApi/controller/editorapi"
"editorApi/middleware"
"github.com/gin-gonic/gin"
)
func InitActorsRouter(Router *gin.RouterGroup) {
ActorsRouter := Router.Group("editor").Use(middleware.CORSMiddleware(), middleware.JWTAuth())
{
ActorsRouter.POST("actors/create", editorapi.ActorsCreate... |
package main
// Compute the Damerau–Levenshtein distance between a and b.
// Reference: https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance#Distance_with_adjacent_transpositions
func DLDist(a, b string) int {
ra := make([]rune, 0, len(a))
rb := make([]rune, 0, len(b))
for _, r := range a {
ra = app... |
// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
package extensions
import (
"bytes"
"encoding/binary"
"io"
"math/bits"
)
const (
uint64Size = 8
firstCustomTypeID = 65
encFirstCustomTypeID = 130 // encoded 65
)
// hardcoded initial part of Revocation gob encoding, i... |
package main
import (
"encoding/json"
"fmt"
"math/rand"
"time"
"github.com/hmgle/chi"
"github.com/hmgle/chi/middleware"
"github.com/hmgle/chi/render"
"github.com/valyala/fasthttp"
"golang.org/x/net/context"
)
func main() {
r := chi.NewRouter()
r.Use(middleware.RequestID)
// r.Use(middleware.Logger)
r.... |
package register
import (
"context"
"fmt"
"net/http"
"os"
"time"
"github.com/sirupsen/logrus"
"github.com/rancher/fleet/internal/config"
"github.com/rancher/fleet/internal/registration"
fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
"github.com/rancher/fleet/pkg/durations"
fleetcontrol... |
package script
import (
"strings"
)
var Directions = []string{"north", "south", "east", "west", "up", "down"}
// FIX: move these into a standard rules extension package?
func _makeOpposites() map[string]string {
op := make(map[string]string)
for i := 0; i < len(Directions)/2; i++ {
a, b := Directions[2*i], Dire... |
package tc
import (
"bufio"
"encoding/binary"
"fmt"
"io"
"strconv"
"strings"
"t3x9/ast"
"t3x9/lex"
)
const bpw = 4
const (
opush = "00"
oclear = "01"
oldval = "02,w"
oldaddr = "03,a"
oldlref = "04,w"
oldglob = "05,a"
oldlocl = "06,w"
ostglob = "07,a"
ostlocl = "08,w"
ostindr ... |
package array
import (
"github.com/project-flogo/core/data"
"github.com/project-flogo/core/data/expression/function"
"github.com/project-flogo/core/support/log"
"reflect"
)
type appendFunc struct {
}
func init() {
function.Register(&appendFunc{})
}
func (a *appendFunc) Name() string {
return "append"
}
func ... |
// Copyright 2020 The VectorSQL Authors.
//
// Code is licensed under Apache License, Version 2.0.
package optimizers
import (
"testing"
"planners"
"github.com/stretchr/testify/assert"
)
func TestOptimizePredicatePushDown(t *testing.T) {
plan := planners.NewMapPlan(
planners.NewScanPlan("tables", "system"),
... |
package troubleshoot
import (
"context"
"net/http"
"testing"
dynatracev1beta1 "github.com/Dynatrace/dynatrace-operator/src/api/v1beta1"
"github.com/Dynatrace/dynatrace-operator/src/dtclient"
"github.com/Dynatrace/dynatrace-operator/src/kubeobjects/address"
"github.com/Dynatrace/dynatrace-operator/src/scheme"
... |
// Copyright 2021 Comcast Cable Communications Management, LLC
//
// 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 ... |
package controller
import (
"encoding/json"
"gm/method"
"io/ioutil"
"net/http"
"shared/utility/errors"
"shared/utility/glog"
"shared/utility/httputil"
"shared/utility/safe"
"sync"
)
type Dispatcher struct {
f sync.Map
filters []HttpRequestFilter
}
func (d *Dispatcher) ServeHTTP(w http.ResponseWriter... |
// Copyright 2020 The VectorSQL Authors.
//
// Code is licensed under Apache License, Version 2.0.
package datavalues
import (
"strconv"
"unsafe"
"base/docs"
"base/errors"
)
type ValueFloat float64
func MakeFloat(v float64) IDataValue {
r := ValueFloat(v)
return &r
}
func ZeroFloat() IDataValue {
r := Valu... |
package main
import (
"bufio"
"flag"
"fmt"
"log"
"os"
"github.com/ipkg/blockchain"
)
func init() {
flag.Parse()
log.SetFlags(log.Lshortfile | log.LstdFlags)
}
func main() {
kp := blockchain.GenerateNewKeypair()
chain := blockchain.NewBlockchain(kp, nil)
go chain.Run()
go func() {
for {
select {
... |
package iterators_test
import (
"testing"
"github.com/adamluzsi/frameless/ports/iterators"
"github.com/adamluzsi/testcase/assert"
)
var _ iterators.Iterator[string] = iterators.Slice([]string{"A", "B", "C"})
func TestNewSlice_SliceGiven_SliceIterableAndValuesReturnedWithDecode(t *testing.T) {
t.Parallel()
i ... |
package main
import (
"fmt"
"os"
"sync"
)
var wg sync.WaitGroup
var commandQueue sync.WaitGroup
var isShutdown bool
const (
InfoColor = "\033[1;34m%s\033[0m\n"
NoticeColor = "\033[1;36m%s\033[0m\n"
WarningColor = "\033[1;33m%s\033[0m\n"
ErrorColor = "\033[1;31m%s\033[0m\n"
DebugColor = "\033[0;36m%s... |
package ino
import (
"math"
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/go-inovation/ino/internal/audio"
"github.com/hajimehoshi/go-inovation/ino/internal/draw"
"github.com/hajimehoshi/go-inovation/ino/internal/field"
"github.com/hajimehoshi/go-inovation/ino/internal/fieldtype"
"github.com/hajimeh... |
package roman
import (
"testing"
)
// func Test_D(t *testing.T) {
// got := ToInt("MDCXCV")
// t.Fatal(got)
// }
func Test_Examples(t *testing.T) {
examples := []struct {
want int
roman string
}{
{1, "I"},
{2, "II"},
{3, "III"},
{4, "IV"},
{5, "V"},
{6, "VI"},
{7, "VII"},
{8, "VIII"},
{9... |
package worldlight
import (
"github.com/go-gl/mathgl/mgl32"
)
/* Assuming this is 8bits
enum emittype_t
{
emit_surface, // 90 degree spotlight
emit_point, // simple point light source
emit_spotlight, // spotlight with penumbra
emit_skylight, // directional light with no falloff (surface must trace to SKY te... |
package handler
import (
"context"
"github.com/zzsds/micro-sms-service/service"
"github.com/jinzhu/gorm"
"github.com/micro/go-micro/v2/errors"
"github.com/zzsds/micro-sms-service/models"
"github.com/zzsds/micro-sms-service/modules/provider"
"github.com/zzsds/micro-sms-service/proto/sms"
)
// Sms ...
type Sms... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.