text stringlengths 11 4.05M |
|---|
package Word_Ladder
import "math"
func ladderLength(beginWord string, endWord string, wordList []string) int {
wordId := make(map[string]int)
graph := make([][]int, 0)
addWord := func(word string) int {
id, has := wordId[word]
if has {
return id
}
wordId[word] = len(wordId)
graph = append(graph, []in... |
package id_035
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
type ListNode struct {
Val int
Next *ListNode
}
/*
思路1:双指针法
给定两个链表的指针p1, p2分别标记l1, l2
对p1,p2所指的节点进行比较将小的插入到新的链表中
如果两边都比较完成之后、还有多余的元素没有插入、说明未插入元素比前面的都大、直接追加到后面
*/
func mergeTwoLists(... |
package problem0012
func intToRoman(num int) string {
m := map[int]string{
1: "I",
4: "IV",
5: "V",
9: "IX",
10: "X",
40: "XL",
50: "L",
90: "XC",
100: "C",
400: "CD",
500: "D",
900: "CM",
1000: "M",
}
carry, remainder := 1, 0
res := ""
for num != 0 {
remainder... |
package servermiddleware
import (
"bytes"
"encoding/json"
"github.com/gin-gonic/gin"
"io/ioutil"
"net/http"
redis "xj_web_server/cache"
"xj_web_server/module"
"xj_web_server/util"
"xj_web_server/util/jwt"
//"strconv"
)
//type BaseAuthReq struct {
// BaseReq
// Uid int `form:"uid" json:"uid" binding:"requir... |
package http
// WatchRequest is /watch request model
type WatchRequest struct {
Service string `json:"service"` // Service name (to differentiate multiple requestors): 1..64
PublicKeys []string `json:"public_keys"` // Destination wallet address in Base58
Callback string `json:"callback"` // Callback... |
package main
import (
"fmt"
"io/ioutil"
)
func main() {
fmt.Println("Largest Power - Ranking!!")
dat, err := ioutil.ReadFile("./bench.out")
if err != nil {
panic(err)
}
fmt.Print(string(dat))
}
|
package main
import (
"encoding/hex"
"fmt"
"net"
"os"
"strconv"
)
func stringHex2Binary(strHex string) (string, error) {
strByte := []byte(strHex)
strBianry := ""
for _, data := range strByte {
str, err := strconv.ParseInt(string(data), 16, 10)
if err != nil {
return "", err
}
str... |
package main
import (
"github.com/mitchellh/cli"
"github.com/pragkent/aliyun-disk/command"
)
func Commands(meta *command.Meta) map[string]cli.CommandFactory {
return map[string]cli.CommandFactory{
"init": func() (cli.Command, error) {
return &command.InitCommand{
Meta: *meta,
}, nil
},
"attach": fu... |
/*
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 main
import "fmt"
const TestVersion = 1
func main() {
var (
input string
)
fmt.Print("Enter a name! \n> ")
fmt.Scanln(&input)
fmt.Println(HelloWorld(input))
}
func HelloWorld(input string) string {
if input == "" {
input = "World"
}
return "Hello, " + input + "!"
}
|
package tappx
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"regexp"
"strconv"
"text/template"
"time"
"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/errortypes"
"github.com/prebid/prebid-s... |
package main
import "fmt"
//一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。
//
// 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。
//
// 现在考虑网格中有障碍物。那么从左上角到右下角将会有多少条不同的路径?
//
//
//
// 网格中的障碍物和空位置分别用 1 和 0 来表示。
//
// 说明:m 和 n 的值均不超过 100。
//
// 示例 1:
//
// 输入:
//[
// [0,0,0],
// [0,1,0],
// [0,0,0]
//]
//输出: 2
//解释:
/... |
package cmd
import (
"context"
"io"
"os/exec"
"runtime"
"strings"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tilt-dev/tilt/internal/localexec"
"github.com/tilt-dev/tilt/internal/testutils"
"github.com/tilt-dev/tilt/internal/testutils/bufsync"
... |
// Code generated; DANGER ZONE FOR EDITS
package data
import (
"bytes"
"encoding/json"
"fmt"
"gopkg.in/yaml.v2"
)
const PresentationNodeDefinitionName = "presentation-node"
type PresentationNodeDefinitions map[string]PresentationNodeDefinition
func (d PresentationNodeDefinitions) Keys() (out []string) {
for k... |
// 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 main
import (
"flag"
"fmt"
"io"
"log"
"math/rand"
"net/http"
"os"
"time"
)
func main() {
var (
port = flag.String("port", env("PORT", "8080"), "The port")
)
flag.Parse()
args := flag.Args()
if len(args) < 1 {
log.Fatal("You must specify the `server` or `worker` subcommand.")
}
cmd := args... |
package main
import "fmt"
type node struct {
data int
next *node
}
type list struct {
root *node
count int
}
func (l *list) insert(data int) {
var n *node
if l.root == nil {
n = &node{
data: data,
}
} else {
n = &node{
data: data,
next: l.root,
}
}
l.root = n
l.count += 1
}
func (l *list... |
package easyws
//====================================================================
// hub maintains the set of active connections and broadcasts messages to connections.
type wshub struct {
// Registered connections.
connections map[int64]WebsocketTalker
server *WsServer
// Inbound messages fro... |
package repository
import (
"encoding/json"
"log"
"time"
"va_test_a/internal/model"
"va_test_a/pkg/database"
)
type ToDoRepository interface {
CreateTask(string,string, time.Time) bool
GetTasks(string) []model.ToDo
}
type ToDoRepo struct {
}
func (t ToDoRepo) CreateTask(userName string,task string, date time... |
package bfs
import "github.com/victorfernandesraton/bfs-and-dfs/node"
// Execution é a função que pega um vertice de uma arvore qualquer e implementa o algoritimo
func Execution(n *node.Node, out *node.Output) *node.Output {
// Marca o vertice raiz como usado
if n.Used == false {
n.Used = true
out.Queue = appen... |
package algo_test
import (
"testing"
"github.com/bpatel85/learn-go/pkg/algo"
)
type FindPathTestStructs struct {
input [][]int
expected int
}
func TestNumPaths(t *testing.T) {
testRuns := []FindPathTestStructs{
{
input: [][]int{
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
},
expected: 6,
},
... |
package foo
// Comment for struct
type Foo struct {
// comment before
a string // comment at same line
// comment after
b []string
// comment after without fields following
}
func newFoo() Foo {
return Foo{
// comment before
a: "a", // comment at same line
// comment after
b: []string{
// comment bef... |
package controllers
import (
"github.com/astaxie/beego"
)
type AddUpController struct {
beego.Controller
}
// 文章更新 数据校验 路由 /api/article/update
func (this *AddUpController) AddUp() {
//this.Layout = layout
//this.TplName = theme + "/tongji.html"
this.TplName = theme + "/tongji.html"
}
|
package extractpublicfiles
import (
"context"
"errors"
"fmt"
"github.com/function61/gokit/ezhttp"
"github.com/function61/gokit/fileexists"
"github.com/function61/passitron/pkg/tarextract"
"io"
"log"
"net/url"
"os"
)
const (
PublicFilesArchiveFilename = "public.tar.gz"
publicFilesDirectory = "public"... |
package acrostic
import (
"errors"
"github.com/noyuno/lgo/runes"
)
// CaseElement : 格要素側(PredicateのCaseElementGroup(格要素群)ではない)
type CaseElement struct {
// knpの基本句の出力行
BasicPhrase []rune
// AnalysisCase : 解析格(被連体修飾詞以外)
AnalysisCase []rune
// HasAnalysisCase : 解析格を持つかどうか
HasAnalysisCase bool
// AnalysisCon... |
/*
* @Author: CJ Ting
* @Date: 2016-06-02 20:53:54
* @Last Modified by: dingxijin
* @Last Modified time: 2016-06-02 23:18:47
*/
package main
import (
"flag"
"fmt"
"io"
"log"
"net"
"time"
)
func main() {
port := flag.Int("port", 5000, "specify the port")
flag.Parse()
listener, err := net.Listen("tcp", f... |
package main
import (
"github.com/Cloud-Foundations/Dominator/lib/log"
"github.com/Cloud-Foundations/golib/pkg/loadbalancing/dnslb/config"
)
func rollingReplaceSubcommand(args []string, logger log.DebugLogger) error {
for _, region := range args {
if err := config.RollingReplace(cfgData, region, logger); err != ... |
package template
import "github.com/spf13/cobra"
var RootCMD = &cobra.Command{
Use: "template",
Short: "Commands to create pre-filled templates for jobs",
Long: ``,
}
func init() {
RootCMD.AddCommand(customerCMD)
RootCMD.AddCommand(applicationCMD)
}
|
package model
import (
"context"
"encoding/json"
"errors"
"fmt"
"github.com/olivere/elastic/v7"
"lhc.go.game.center/libs/es"
"lhc.go.game.center/logs"
)
type NetbianImg struct {
Id string `json:"id"`
Name string `json:"name"`
Alt string `json:"alt" form:"alt"`
Details string `json:"details"`
Src string ... |
package main
import (
"./models"
//"github.com/gorilla/websocket"
"net/http"
"html/template"
"github.com/gorilla/mux"
)
var templates *template.Template
func main() {
models.New()
setupRoutes()
}
func setupRoutes() {
r := mux.NewRouter()
bal := models.GetBalance()
templates = template.Must(template.Par... |
package authorization
import (
"context"
"github.com/G-Research/armada/internal/armada/authorization/permissions"
)
type Owned interface {
GetUserOwners() []string
GetGroupOwners() []string
}
type PermissionChecker interface {
UserHasPermission(ctx context.Context, perm permissions.Permission) bool
UserOwns(c... |
package swagger2gql
import (
"github.com/pkg/errors"
"github.com/EGT-Ukraine/go2gql/generator/plugins/graphql"
"github.com/EGT-Ukraine/go2gql/generator/plugins/swagger2gql/parser"
)
var scalarsResolvers = map[parser.Kind]graphql.TypeResolver{
parser.KindBoolean: graphql.GqlBoolTypeResolver,
parser.KindFloat64:... |
package main
import (
"algogrit.com/fib-grpc/pkg/auth"
grpcMiddleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpc_auth "github.com/grpc-ecosystem/go-grpc-middleware/auth"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"google.golang.org/grpc"
)
func withServerUnaryInterceptor(enableAuth b... |
// 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 generator
import (
"testing"
)
var aliasTests = []struct {
alias string
result bool
}{
{"simplealias", true},
{"simple-alias", true},
{"simple.alias", true},
{"simple/alias", true},
{"simple@alias", true},
{"simple@alias.com", true},
{".simplealias", false},
{"/simplealias", false},
}
func TestIs... |
package main
import (
"time"
)
type CommandQueue struct {
RPS int
ChunkSize int
CommandsCh chan VKCommand
ChunksCh chan VKCommandsChunk
}
func NewCommandsQueue(rps int) *CommandQueue {
return &CommandQueue{
RPS: rps,
ChunkSize: 25,
CommandsCh: make(chan VKCommand),
ChunksCh: make(ch... |
package controller
import (
"github.com/kataras/iris"
"go-iris-mv/model"
)
func (idb* InDB) CreteUser(ctx iris.Context) {
var (
user model.User
)
ctx.ReadJSON(&user)
idb.DB.Create(&user)
ctx.JSON(iris.Map{
"error" : "false",
"status" : iris.StatusOK,
"result" : user,
})
}
func (idb* InDB) GetAll(ctx ... |
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
//
package store
import (
"testing"
"time"
"github.com/mattermost/mattermost-cloud/internal/testlib"
"github.com/mattermost/mattermost-cloud/model"
"github.com/stretchr/testify/assert"
"github.com/st... |
/*
* 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
import (
"time"
)
type... |
package syncutils
import (
"fmt"
"sync"
"time"
"github.com/iotaledger/hive.go/ds/types"
"github.com/iotaledger/hive.go/runtime/debug"
"github.com/iotaledger/hive.go/runtime/timeutil"
"github.com/iotaledger/hive.go/stringify"
)
// A StarvingMutex is a reader/writer mutual exclusion lock that allows for starvat... |
package main
import (
"io"
"os"
"fmt"
"github.com/xiaq/sxed"
)
const (
READ_BLOCK = 4 * 1024
)
var usage = `Usage: sxed PROGRAM`
func slurp(f *os.File) ([]byte, error) {
bs := make([]byte, 0, READ_BLOCK)
for {
b := make([]byte, READ_BLOCK)
_, err := f.Read(b)
switch err {
case nil:
bs = append(bs,... |
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... |
package stack
type MinValueStackOpt struct {
}
func (stack *MinValueStackOpt) Pop() int {
return 0
}
func (stack *MinValueStackOpt) Push(value int) bool {
return false
}
func (stack *MinValueStackOpt) Peek() int {
return 0
}
func (stack *MinValueStackOpt) Empty() bool {
return false
}
func (stack *MinValueSta... |
package main
import "fmt"
func removeDuplicates(nums []int) []int {
if len(nums) == 0{
return []int{}
}
i:=0
for j:=1;j<len(nums);j++{
if nums[j]!=nums[i]{
i++
nums[i] = nums[j]
}
}
return nums[:i+1]
}
func main() {
nums := []int{1,1,2}
output := removeDuplicates(nums)
fmt.Printl... |
// Copyright 2018 Google 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
package main
import "github.com/codingXiang/gecko/cmd"
//go:generate go run main.go general model -s ./example -f user.go -d ./output/model
//go:generate go run main.go general repo -s ./output/model -f user.go -d ./output/module -p user
//go:generate go run main.go general svc -s ./output/model -f user.go -d ./outpu... |
package main
import (
"bufio"
"fmt"
"io"
"os"
"sort"
"strconv"
)
func main() {
solve(os.Stdin, os.Stdout)
}
func solve(stdin io.Reader, stdout io.Writer) {
sc := bufio.NewScanner(stdin)
sc.Scan()
n, _ := strconv.Atoi(sc.Text())
sc.Scan()
r, _ := strconv.Atoi(sc.Text())
x := []int{}
for i := 0; i < n; i... |
package sshttp
import (
"bytes"
"io"
"mime"
"net/http"
"os"
"path/filepath"
"strconv"
"time"
"github.com/pkg/sftp"
"golang.org/x/crypto/ssh"
)
const (
// sftpNoSuchFile is the error code returned by SFTP if access is attempted
// to a file which does not exist.
sftpNoSuchFile = 2
)
// RoundTripper impl... |
package sqlstore
import (
"bytes"
"fmt"
"github.com/ssok8s/ssok8s/pkg/bus"
m "github.com/ssok8s/ssok8s/pkg/models"
"github.com/ssok8s/ssok8s/pkg/util"
"strconv"
"strings"
"time"
)
func init() {
bus.AddHandler("sql", CreateUser)
bus.AddHandler("sql", DeleteUserByUsername)
bus.AddHandler("sql", DeleteUser)
... |
/*
İki çeşit map tanımlama
Map içinde key var mı sorgusu
Map den item silme
For ile map içinde dönme
new ile make arasındaki fark: new poinder döner
*/
package main
import "fmt"
func main() {
m1 := make(map[string]int)
m1["k1"] = 1
m1["k2"] = 2
fmt.Println("m1:", m1)
delete(m1, "k1")
fmt.Println("m1:", m1... |
// Package main ...
package main
import (
"log"
"time"
"github.com/go-rod/rod"
)
// This example demonstrates how to use a selector to click on an element.
func main() {
page := rod.New().
MustConnect().
Trace(true). // log useful info about what rod is doing
Timeout(15 * time.Second).
MustPage("https://... |
package main
import (
"flag"
"log"
"net/http"
"os"
"github.com/RackHD/ipam/controllers"
"github.com/RackHD/ipam/ipam"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"gopkg.in/mgo.v2"
)
var mongo string
func init() {
flag.StringVar(&mongo, "mongo", "ipam_mongo:27017", "port to connect to mongodb c... |
package utils
import (
"encoding/json"
"fmt"
"time"
)
type TimeStringBetween struct {
Src []string
start time.Time
end time.Time
}
func NewTimeStringBetween(data []byte) (*TimeStringBetween, error) {
t := &TimeStringBetween{}
err := json.Unmarshal(data, t)
if err != nil {
return nil, err
}
return t,... |
package collect
import (
"bytes"
"encoding/json"
"fmt"
"strings"
"github.com/go-redis/redis/v7"
"github.com/pkg/errors"
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
)
func Redis(c *Collector, databaseCollector *troubleshootv1beta2.Database) (CollectorResult, error) ... |
package main
import (
"bytes"
"fmt"
"go/ast"
"go/format"
"go/parser"
"go/printer"
"go/token"
"log"
"os"
"strings"
"./rewriter"
"golang.org/x/tools/go/ast/astutil"
)
// TODO: comments are moved around by this script. Look at go/ast's CommentMap
// https://golang.org/pkg/go/ast/#CommentMap
// This scri... |
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package camera
import (
"context"
"fmt"
"regexp"
"chromiumos/tast/common/media/caps"
"chromiumos/tast/common/testexec"
"chromiumos/tast/errors"
"chromiumos/tast/loca... |
package main
import (
"bytes"
"crypto/tls"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"net"
"net/http"
"time"
"golang.org/x/crypto/ssh/terminal"
"github.com/gertd/pdbq/helper"
)
// Token - Puppet RBAC token
type Token struct {
Token string `json:"token"`
}
func main() {
var token Token
var host... |
package accounts
import (
"testing"
"github.com/google/uuid"
"github.com/jrapoport/gothic/models/account"
"github.com/jrapoport/gothic/models/types"
"github.com/jrapoport/gothic/models/types/provider"
"github.com/jrapoport/gothic/store"
"github.com/jrapoport/gothic/test/tconn"
"github.com/jrapoport/gothic/tes... |
package backends
import (
"database/sql"
"errors"
"fmt"
"log"
"strings"
"sync"
"time"
)
const (
dbTypePostgres = "postgres"
dbTypeMysql = "mysql"
)
// Opt represents SQL DB backend's options.
type Opt struct {
DBType string
ResultsTable string
UnloggedTables bool
}
// sqlDB represents the s... |
package solutions
func findDisappearedNumbers(nums []int) []int {
for i := 0; i < len(nums); i++ {
for nums[i] != i + 1 {
current := nums[i]
if nums[current - 1] == current {
break
} else {
nums[i], nums[current - 1] = nums[current - 1], ... |
package main
import (
envstruct "code.cloudfoundry.org/go-envstruct"
)
// Config is the configuration for a MetricStore.
type Config struct {
LogProviderAddr string `env:"LOGS_PROVIDER_ADDR, required, report"`
LogsProviderTLS LogsProviderTLS
MetricStoreAddr string `env:"METRIC_STORE_ADDR, required, report"`
Met... |
package image
import (
"sync"
)
// Grayscale turns the images to grayscale.
func (img *Image) Grayscale(algorithm int) *Image {
var wg sync.WaitGroup
for rowIndex := 0; rowIndex < img.Height; rowIndex++ {
wg.Add(1)
go (func(rowIndex int, img *Image) {
for colIndex := 0; colIndex < img.Width; colIndex++ {
... |
package eventstore
import (
"context"
"time"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/auth/repository/eventsourcing/view"
"github.com/caos/zitadel/internal/auth_request/model"
cache "github.com/caos/zitadel/internal/auth_request/repository"
"github.com/caos/zitadel/internal/errors"
es_mode... |
package main
import "fmt"
func imprimir() string {
fmt.Println("Imprimindo...")
return "VALOR de IMPRIMIR"
}
func main() {
defer fmt.Println(imprimir())
fmt.Println("2")
fmt.Println("3")
}
//stack
// topo
fmt.Println(imprimir())
fmt.Println(imprimir())
fmt.Println(imprimir())
// fundo
// execucao:
// f... |
package config
import (
"flag"
"log"
"os"
"strconv"
"strings"
)
var globalConfig ApplicationConfig
// ApplicationConfig stores all of the input parameters.
type ApplicationConfig struct {
LogFolders []string // Folders that should be watched for changes.
GrpcBackends []string // gRPC backends to send data t... |
package main
import "fmt"
var sentence string
var emptyString string = ""
var no, yes, maybe = "no", "yes", "maybe"
func main() {
output()
}
func output() {
m := `hello
string \n ` // does not escape any characters in a string
fmt.Println(m)
fmt.Println(sentence)
fmt.Println(emptyString)
fmt.Println(no, yes, ... |
package params
import (
"fmt"
)
const (
VersionMajor = 0 // Major version component of the current release
VersionMinor = 0 // Minor version component of the current release
VersionPatch = 0 // Patch version component of the current release
VersionMeta = "unstable" // V... |
package codegen
import (
"fmt"
"testing"
)
func TestPrinter(t *testing.T) {
fmt.Println(DeclPackage("some_package"))
fmt.Println(DeclType("Test", "int"))
}
|
package security_signout_reply
import (
"encoding/xml"
"github.com/tmconsulting/amadeus-ws-go/formats"
)
type SecuritySignOutReply struct {
XMLName xml.Name `xml:"http://xml.amadeus.com/VLSSOR_04_1_1A Security_SignOutReply"`
ErrorSection *ErrorSection `xml:"errorSection,omitempty"`
// This segment is only use... |
package gadwords
import (
"encoding/xml"
"fmt"
"log"
"testing"
"time"
)
func testCampaignService(t *testing.T) (service *CampaignService) {
return &CampaignService{Auth: testAuthSetup22(t)}
}
func testCampaign(t *testing.T) (Campaign, func()) {
budget, cleanupBudget := testBudget(t)
cs := testCampaignService... |
/*
MIT License
Copyright (c) 2020-2021 Kazuhito Suda
This file is part of NGSI Go
https://github.com/lets-fiware/ngsi-go
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, inc... |
// 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 ui
import (
"context"
"net/http"
"net/http/httptest"
"path/filepath"
"regexp"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/lo... |
package gnet
import (
guid "github.com/satori/go.uuid"
)
// SimpleGuacamoleTunnel ==> AbstractGuacamoleTunnel
// * GuacamoleTunnel implementation which uses a provided socket. The UUID of
// * the tunnel will be randomly generated.
type SimpleGuacamoleTunnel struct {
AbstractGuacamoleTunnel
/**
* The UUID assoc... |
package main
import (
"log"
"os"
"time"
"persistence"
)
var dbPersistence persistence.Persistence
func init() {
var err error
accessKey := os.Getenv("test1_aws_access_key")
secretKey := os.Getenv("test1_aws_secret_key")
region := os.Getenv("test1_aws_region")
dbPersistence, err = persistence.NewPersisten... |
package contract
import "github.com/fanaticscripter/EggContractor/api"
type ProgressInfo struct {
EggsLaid float64
ProjectedEggsLaid float64
Rewards []*Reward
UltimateGoal float64
}
type Reward struct {
*api.Reward
PercentageOfUltimateGoal float64
PercentageCompleted float64
}
fu... |
package usecase
import (
"errors"
"fmt"
"github.com/go-pg/pg/v10"
"marketplace/accounts/domain"
)
type AdminDeleteUserCmd func(db *pg.DB, userId int64) error
func AdminDeleteUser() AdminDeleteUserCmd {
return func(db *pg.DB, userId int64) error {
user := domain.Account{
Id: userId,
}
err := db.Model(... |
package main
import "fmt"
/*
struct方法中,指针类型的接收者必须是合法指针(包括 nil),或能获取实例地址
*/
type X struct {
}
func (x *X) callmethod() {
fmt.Println("test")
}
func main() {
//nil是合法的调用
var x *X
x.callmethod()
//cannot take the address of X literal, X{}是不可寻址的
//X{}.callmethod()
// 正确处理
a := X{}
a.callmethod()
findItemIn... |
// 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 lcs_test
import (
"bytes"
"fmt"
"hash/fnv"
"reflect"
"strings"
"testing"
"unicode/utf8"
"cloudeng.io/algo/codec"
"cloudeng.io/algo/lcs"
"cl... |
package main
//689. 三个无重叠子数组的最大和
//给你一个整数数组 nums 和一个整数 k ,找出三个长度为 k 、互不重叠、且3 * k 项的和最大的子数组,并返回这三个子数组。
//
//以下标的数组形式返回结果,数组中的每一项分别指示每个子数组的起始位置(下标从 0 开始)。如果有多个结果,返回字典序最小的一个。
//
//
//
//示例 1:
//
//输入:nums = [1,2,1,2,6,7,5,1], k = 2
//输出:[0,3,5]
//解释:子数组 [1, 2], [2, 6], [7, 5] 对应的起始下标为 [0, 3, 5]。
//也可以取 [2, 1], 但是结果 [1, 3... |
// 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 video
import (
"context"
"net/http"
"time"
"chromiumos/tast/common/media/caps"
"chromiumos/tast/local/bundles/cros/video/play"
"chromiumos/tast/local/chrome/b... |
package main
/*
#include <freerdp/graphics.h>
*/
import "C"
import (
"log"
)
//export webRdpBitmapNew
func webRdpBitmapNew(context *C.rdpContext, bitmap *C.rdpBitmap) C.BOOL {
log.Println("webRdpBitmapNew")
return C.TRUE
}
//export webRdpBitmapFree
func webRdpBitmapFree(context *C.rdpContext, bitmap *C.rdpBitmap)... |
package main
import (
"fmt"
"os"
"strconv"
)
/*
Passos do quicksort:
1)Escolher um elemento da lista como pivô e removê-lo da lista;
2)Particionar a lista em duas listas distintas: uma contendo elementos menores que o pivô e outra os maiores;
3)Ordenar as duas listas recursivamente;
4)Retornar a combinação da list... |
// 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 reconcilers
import (
"context"
"fmt"
marin3rv1alpha1 "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1"
xdss "github.com/3scale-ops/marin3r/pkg/discoveryservice/xdss"
envoy "github.com/3scale-ops/marin3r/pkg/envoy"
envoy_resources "github.com/3scale-ops/marin3r/pkg/envoy/resources"
envoy_serializer ... |
package repository
import (
"database/sql"
"ehsan_esmaeili/model"
"fmt"
)
type Buy_ChargRepository interface {
Insert(user *model.Buy_Charg) (use *model.GetaUser, err error )
}
type Buy_ChargRepositorySqlServer struct {
db *sql.DB //64b
table string //4b
//68
}
func NewBuy_ChargRepositorySqlServer(table... |
package trie
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNodeNew(t *testing.T) {
nd := node{}
assert.NotEqual(t, nil, nd)
assert.Equal(t, 0, len(nd.keys))
}
func TestNodeNode(t *testing.T) {
{
nd := node{}
_, err := nd.node([]string{"foo"}, false)
assert.Equal(t, 0, len(nd.keys))... |
package prompt
import "github.com/AlecAivazis/survey/v2"
var loginQ = []*survey.Question{
{
Name: "username",
Prompt: &survey.Input{Message: promptLoginUsername},
Validate: survey.Required,
Transform: survey.Title,
},
{
Name: "password",
Prompt: &survey.Password{
Message: promptLoginPasswor... |
package binance
import (
"encoding/json"
"fmt"
"github.com/go-kit/kit/log/level"
"github.com/gorilla/websocket"
"strings"
)
func (as *apiService) DepthWebsocketLevel(dwr DepthWebsocketRequestLevel) (chan *DepthLevelEvent, chan struct{}, error) {
if dwr.Level == 0 {
dwr.Level = 5
}
url := fmt.Sprintf("wss://... |
//go:generate mockgen -destination mock/move.go . MoveHandler
package handlers
import (
"context"
"path/filepath"
"github.com/k0kubun/pp"
"github.com/raba-jp/primus/pkg/cli/ui"
"github.com/spf13/afero"
"go.uber.org/zap"
"golang.org/x/xerrors"
)
type MoveParams struct {
Src string
Dest string
Cwd string
... |
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
//
package store
import (
"fmt"
"strings"
"testing"
"time"
"github.com/mattermost/mattermost-cloud/internal/testlib"
"github.com/mattermost/mattermost-cloud/model"
"github.com/pborman/uuid"
"github... |
package redis
import (
"context"
"github.com/go-redis/redis"
)
var ctx = context.Background()
var rdb *redis.Client
// Initialize connects to redis
func Initialize() {
rdb = redis.NewClient(&redis.Options{
Addr: "redis:6379",
Password: "",
DB: 0,
})
}
// StoreToken stores csrf token with sessio... |
// Package dfc is a scalable object-storage based caching system with Amazon and Google Cloud backends.
/*
* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
*
*/
package dfc
import (
"encoding/json"
"fmt"
"net/http"
"time"
"github.com/NVIDIA/dfcpub/3rdparty/glog"
)
// enumerated REVS types (opaq... |
// Copyright 2022 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... |
// 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... |
// 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 main
import (
"fmt"
"log"
"net"
"net/http"
"net/rpc"
"strings"
)
// rpc包提供了通过网络或其他I/O连接对一个对象的导出方法的访问
// 服务端注册一个对象,使它作为一个服务被暴露,服务的名字是该对象的类型名
// 注册之后,对象的导出方法就可以被远程访问
// 服务端可以注册多个不同类型的对象(服务),但注册具有相同类型的多个对象是错误的
func main() {
// rpc服务端到客户端的完整示例
example()
example2()
}
type Hello struct {}
func (h *Hello... |
/*
* REST API
*
* Rockset's REST API allows for creating and managing all resources in Rockset. Each supported endpoint is documented below. All requests must be authorized with a Rockset API key, which can be created in the [Rockset console](https://console.rockset.com). The API key must be provided as `ApiKey <ap... |
package handlers
import (
"fmt"
"github.com/gabrielroriz/fineasy/database"
)
func InsertDBConfig() *database.DBConfig {
dbConfig := database.DBConfig{}
fmt.Printf("host: ")
fmt.Scanf("%s", &(dbConfig.Host))
fmt.Printf("port: ")
fmt.Scanf("%s", &(dbConfig.Port))
fmt.Printf("database: ")
fmt.Scanf("%s", &... |
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
)
var codes []string
func main() {
codes = append(codes, "abc", "def", "fgh","ijk")
http.HandleFunc("/", get)
http.ListenAndServe(":9093", nil)
}
func get(w http.ResponseWriter, r *http.Request) {
jsoResult, err := json.Marshal(codes)
if err != ... |
package game
import "github.com/gorilla/websocket"
type Player struct {
BaseObject
Username string `json:"username"`
Password string `json:"password"`
Socket *websocket.Conn `json:"-"`
}
func NewPlayer(chunk *Chunk, socket *websocket.Conn) *Player {
player := &Player{
BaseObject: *NewBaseO... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.