text stringlengths 11 4.05M |
|---|
// 杨辉三角
// 每行除两边元素为 1 外,每个元素 nums[i][j] = nums[i-1][j-1]+nums[i-1][j]
package pascalstriangle
func generate(numRows int) [][]int {
var result [][]int
for i := 1; i <= numRows; i++ {
var row []int
for j := 0; j < i; j++ {
if j == 0 || j == i-1 {
row = append(row, 1)
} else {
row = append(row, resul... |
package message
import (
"github.com/sudachen/coin-exchange/exchange"
"github.com/sudachen/coin-exchange/exchange/channel"
"sync"
"time"
)
type Api interface {
Subscribe([]exchange.CoinPair, ...channel.Channel) error
IsSupported(exchange.CoinPair) bool
FilterSupported([]exchange.CoinPair) []exchange.CoinPair
... |
package drivers
import (
"fmt"
log "github.com/Sirupsen/logrus"
"github.com/docker/go-plugins-helpers/volume"
"os"
"strings"
"sync"
)
const (
NfsOptions = "nfsopts"
DefaultNfsV3 = "port=2049,nolock,proto=tcp"
)
type nfsDriver struct {
root string
version int
mountm *mountManager
m *sync.Mutex
... |
package spec
import (
"github.com/waybeams/waybeams/pkg/events"
)
type CharCallback func(r rune)
type Window interface {
ResizableWriter
ResizableReader
BeginFrame()
Close()
EndFrame()
FrameRate() int
Init()
OnResize(handler events.EventHandler) events.Unsubscriber
PixelRatio() float64
PollEvents()
Shou... |
package vardiff
import (
"github.com/mining-pool/not-only-mining-pool/config"
"time"
)
type VarDiff struct {
Options *config.VarDiffOptions
BufferSize int64
MaxTargetTime float64
MinTargetTime float64
TimeBuffer *RingBuffer
LastRtc int64
LastTimestamp int64
}
func NewVarDiff(options *conf... |
package data
//
// Copyright (c) 2019 ARM Limited.
//
// SPDX-License-Identifier: MIT
//
// 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 limit... |
package main
import (
"fmt"
"math"
)
func Max(a, b int) int {
if a > b {
return a
}
return b
}
func maxProfit(prices []int) int {
prices = append(prices, 0)
d1 := [2]int{-prices[0], math.MinInt32}
d2 := [2]int{math.MinInt32, math.MinInt32}
for i := 1; i < len(prices)-1; i++ {
d2[1] = Max(d2[1], d1[1]+pri... |
package reddit
import (
"database/sql"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strconv"
"sync"
"github.com/jonreiter/govader"
)
type Sentiment struct {
SentimentPos float64 `db:"sentiment_pos"`
SentimentNeg float64 `db:"sentiment_neg"`
SentimentNeu float64 `db:"sentiment_neu"`
Sentiment... |
package main
import (
"crypto/x509"
"encoding/pem"
"fmt"
"net/http"
"os"
"regexp"
"strings"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
_ "github.com/rkilburn/Traefik-ForwardAuth-Certs/docs"
echoSwagger "github.com/swaggo/echo-swagger" // echo-swagger middleware
"go.elastic.co/a... |
package main
import (
"os"
"os/signal"
"syscall"
"time"
"github.com/micjoh/go-pinboard"
"github.com/namsral/flag"
logger "github.com/sirupsen/logrus"
pinenricher "github.com/amcleodca/pretty-pinboard/pin-enricher"
enricher "github.com/amcleodca/pretty-pinboard/pin-enricher/enricher"
)
func main() {
var po... |
package pgmigrate
import (
"database/sql"
"fmt"
_ "github.com/lib/pq"
)
// Sql structure for sql
type Sql struct {
DB *sql.DB
}
// Config DB connection
type Config struct {
DBname string
Host string
User string
Password string
Port string
SSLMode string
Runtim... |
package dao
import (
"errors"
"mall/app/api/web/member/model"
"sync"
"github.com/jinzhu/gorm"
)
var updateCreditLock sync.Mutex
func (d *Dao) UpdateCredit(arg model.UpdateCreditParam) error {
if arg.Uniacid == 0 {
return errors.New("无效的应用ID")
}
if arg.Openid == "" {
return errors.New("无效的用户Openid")
}
... |
package moddep
const TEST = "testing"
|
package utils
// GetMiddlewares : asdasd
func GetMiddlewares() {
}
|
/*
* @lc app=leetcode.cn id=95 lang=golang
*
* [95] 不同的二叉搜索树 II
*
* https://leetcode.cn/problems/unique-binary-search-trees-ii/description/
*
* algorithms
* Medium (72.93%)
* Likes: 1348
* Dislikes: 0
* Total Accepted: 153.6K
* Total Submissions: 210.6K
* Testcase Example: '3'
*
* 给... |
package tunnel
import (
"context"
"crypto/tls"
"fmt"
"net"
"net/netip"
"os"
"strings"
"time"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v2/altsrc"
"golang.org/x/term"
"github.com/cloudflare/cloudflared/cmd/cloudflared/cliu... |
package dbmigrate
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
)
func TestMain(m *testing.M) {
removeTempStuff()
createTempStuff()
code := m.Run()
removeTempStuff()
os.Exit(code)
}
func createTempStuff() {
removeTempStuff()
os.MkdirAll("test/dir", os.ModeDir|o... |
package rpc
// =====================
// WatchtowerClient and WatchtowerClientClient related RPCs.
// =====================
|
package main
import (
"github.com/01-edu/z01"
)
func main() {
index := 0
var result_string rune
for i := 'z'; i >= 'a'; i-- {
index++
res := index % 2
if res == 0 {
result_string = i - 32
z01.PrintRune(result_string)
} else {
result_string = i
z01.PrintRune(result_string)
}
}
}
|
package aws
import (
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/ddrugeon/s3cleaner/pkg/common"
)
// Client represents an AWS Client
type Client struct {
session *session.... |
//
// Copyright (c) SAS Institute 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 agre... |
// Copyright 2020 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 main
// Leetcode 678. (medium)
func checkValidString(s string) bool {
left := make([]int, len(s))
star := make([]int, len(s))
i, j := 0, 0
for k, r := range s {
if r == '(' {
left[i] = k
i++
} else if r == '*' {
star[j] = k
j++
} else if r == ')' {
if i > 0 {
i--... |
// Copyright 2014 Dirk Jablonowski. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package miscellaneous
import (
"testing"
)
func TestBoolToUint8(t *testing.T) {
a := true
if BoolToUint8(a) != 0x01 {
t.Fatalf("Error TestBoolToUint8: ... |
package leetcode_go
import (
"sort"
)
func combinationSum2(candidates []int, target int) [][]int {
res := [][]int{}
sort.Ints(candidates)
helperP40(candidates, []int{}, target, 0, &res)
return res
}
func helperP40(candidates []int, curSum []int, target int, start int, res *[][]int) {
sum := sumInt(curSum)
if ... |
package etcd_client
import (
"github.com/coreos/etcd/clientv3"
"log"
)
/*
@Desc :
@Time : 2020/3/4 7:01 下午
@Author : Chang yg
@File : etcdCli
*/
const etcdUrl = ""
var EtcdClient *clientv3.Client
func InitClient() {
var err error
EtcdClient, err = clientv3.New(clientv3.Config{ Endpoints: []string{etcdUrl} })
... |
package main
import (
"os"
"os/signal"
"syscall"
"guild/manager"
"shared/utility/glog"
"shared/utility/safe"
)
func listenSignal() {
defer safe.Recover()
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGHUP, syscall.SIGABRT, syscall.SIGTERM, syscall.SIGKILL, syscall.SIGINT /*, syscall.SIGUSR1, s... |
// Copyright 2019 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 lc
import "sort"
// Time: O(n logn)
// Benchmark: 32ms 6.5mb | 66% 97%
func maxProductDifference(nums []int) int {
sort.Ints(nums)
return (nums[len(nums)-1] * nums[len(nums)-2]) - (nums[0] * nums[1])
}
|
// Copyright (c) 2020 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 !windows
// +build !windows
// The tsshd binary is an SSH server that accepts connections
// from anybody on the same Tailscale network.... |
package main
import (
"context"
"github.com/qdm12/golibs/logging"
"github.com/qdm12/golibs/params"
"github.com/qdm12/pingodown/internal/proxy"
)
func main() {
logger, err := logging.NewLogger(logging.ConsoleEncoding, logging.InfoLevel, 0)
if err != nil {
panic(err)
}
envParams := params.Ne... |
package buildkite
import (
"fmt"
"net/http"
"reflect"
"testing"
"time"
)
func TestBuildsService_List(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v2/builds", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `[{"id":"123"},{"id":"1234"}]`)
})
builds, _, ... |
// 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 models
import (
"time"
"github.com/1046102779/common/consts"
"github.com/1046102779/common/types"
"github.com/1046102779/official_account/conf"
. "github.com/1046102779/official_account/logger"
"github.com/pkg/errors"
"github.com/astaxie/beego/orm"
)
type AccountMessageTemplates struct {
Id ... |
package datadogagent
import (
"reflect"
"testing"
apicommon "github.com/DataDog/datadog-operator/apis/datadoghq/common"
datadoghqv1alpha1 "github.com/DataDog/datadog-operator/apis/datadoghq/v1alpha1"
"github.com/DataDog/datadog-operator/apis/datadoghq/v1alpha1/test"
apiutils "github.com/DataDog/datadog-operator... |
package main
import (
"archive/zip"
"io"
"log"
"os"
"path/filepath"
)
func main() {
// Create a reder out of the zip archive
zipReader, err := zip.OpenReader("test.zip")
if err != nil {
log.Fatalln(err)
}
defer zipReader.Close()
// Iterate through each file/dir found in
for _, file := range zipReader.R... |
package main
import (
"fmt"
"log"
"net"
"github.com/SmitSheth/Mini-twitter/internal/config"
"github.com/SmitSheth/Mini-twitter/internal/user"
"github.com/SmitSheth/Mini-twitter/internal/user/storage/etcd"
"github.com/SmitSheth/Mini-twitter/internal/user/storage/memstorage"
pb "github.com/SmitSheth/Mini-twitte... |
package controllers
import (
"net/http"
"strconv"
"github.com/abhishekgautam2808/sampleservice/models"
"github.com/gin-gonic/gin"
)
func FindAll(c *gin.Context) {
var users []models.User
err := models.DB.Find(&users).Error
if err != nil {
c.JSON(http.StatusForbidden, gin.H{
"error": err.Error(),
})
}... |
package txhelper
const (
TxDirectionInvalid int32 = -1
TxDirectionSent int32 = 0
TxDirectionReceived int32 = 1
TxDirectionTransferred int32 = 2
TxTypeRegular = "Regular"
TxTypeCoinBase = "Coinbase"
TxTypeTicketPurchase = "Ticket"
TxTypeVote = "Vote"
TxTypeRevocation =... |
package main
import (
"testing"
)
func TestDefaultPrimeCalc(t *testing.T) {
r := getPrime(defaultMaxNumber)
if defaultMaxNumber != r.Max {
t.Fatalf("Max value not equal to max constant (%d) %d ",
defaultMaxNumber, r.Max)
}
}
func TestArcPrimeCalc(t *testing.T) {
n := 90000
r := getPrime(n)
if n != r... |
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package rpcstatus
import (
"context"
"errors"
"fmt"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"storj.io/drpc/drpcerr"
)
var allCodes = []StatusCode{
Unknown,
OK,
Canceled,
InvalidArgument,
DeadlineExceeded,
N... |
package models
import (
"crypto/md5"
"encoding/hex"
"errors"
"time"
"github.com/rs/xid"
"gopkg.in/mgo.v2/bson"
"../helpers/config"
)
// Shop is shop model
type Shop struct {
ID bson.ObjectId `bson:"_id,omitempty" json:"id"`
UserID bson.ObjectId `bson:"user_id" json:"user_id"`
Platform str... |
/*
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 kitsune
// Subscription represents a subscription resource.
type Subscription struct {
ID string `json:"id"`
Topic string `json:"topic"`
}
|
package model
type Goods struct {
GoodsId int64 `json:"goods_id"`
GoodsName string `json:"goods_name"`
GoodsPrice float64 `json:"goods_price"`
GoodsWeight float64 `json:"goods_weight"`
Image []GoodsImage `json:"image"`
Content string `json:"content"`
}
type GoodsIma... |
package main
// Leetcode 914. (easy)
func hasGroupsSizeX(deck []int) bool {
cnt := make([]int, 10000)
for _, num := range deck {
cnt[num]++
}
g := -1
for _, num := range cnt {
if num == 0 {
continue
}
if g == -1 {
g = num
} else {
g = gcd(g, num)
}
}
return g >= 2
}
|
package main
import (
"Dp/DPfactory/factory"
"fmt"
)
func main() {
f := new(factory.Factory)
p := f.Create("a")
fmt.Println(p.GetName())
p = f.Create("b")
fmt.Println(p.GetName())
}
|
package models
import (
"fmt"
perm "github.com/picatic/go-permission-architect"
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func TestRole(t *testing.T) {
Convey("Role", t, func() {
profile := NewProfile("User", "1")
resource := NewResource("Post", "2")
roleProvider := NewRoleProvider("User", "... |
package plugin
import (
"fmt"
"testing"
xpresource "github.com/crossplane/crossplane-runtime/pkg/resource"
"github.com/crossplane/crossplane-runtime/pkg/resource/fake"
"github.com/hashicorp/terraform/providers"
"github.com/zclconf/go-cty/cty"
k8schema "k8s.io/apimachinery/pkg/runtime/schema"
)
func gvkFixture... |
/*
Copyright 2022 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 redis
import (
"bufio"
"bytes"
"errors"
"fmt"
"net"
"strconv"
"time"
)
// Conn is a connection to a Redis server
type Conn struct {
conn net.Conn
r *bufio.Reader
}
const (
CRLF = "\r\n" // Line terminator in Redis wire protocol
MaxArgSize = 64000 // Maximum acceptable size of a bulk res... |
package mws
type Logger interface {
Debugf(format string, args ...interface{})
Infof(format string, args ...interface{})
Warnf(format string, args ...interface{})
Errorf(format string, args ...interface{})
Printf(format string, args ...interface{})
}
func SetLogger(logger Logger) {
log = logger
}
var log Logge... |
// https://leetcode.com/problems/sort-characters-by-frequency/
package leetcode_go
import (
"sort"
)
type CharCnt struct {
b byte
c int
}
type ByCnt []CharCnt
func (a ByCnt) Len() int { return len(a) }
func (a ByCnt) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByCnt) Less(i, j int) bool { ... |
// SPDX-License-Identifier: MIT
package testdata
const x = "//\""
/// line1
const z = "/**\""
const c = 'c'
/**
* line1
* line2
* line3
*/
|
package main
import (
"github.com/mishuan/itinerary_service/handlers"
"net/http"
)
type Route struct {
Name string
Method string
Pattern string
HandlerFunc http.HandlerFunc
}
type Routes []Route
var routes = Routes{
Route{"Index", "GET", "/", handlers.Index},
Route{"Itineraries Index", "GET"... |
package main
import (
"fmt"
"math"
)
type node struct {
value uint64
left *node
right *node
}
var input uint64
func main() {
input = 600851475143 // cannot use a const because overflow :(
root := factorTree(input)
printTree(root, 0)
}
func isPrimeSqrt(value uint64) bool {
// copied from www.thepolyglotde... |
package Score_After_Flipping_Matrix
func matrixScore(A [][]int) int {
rowLength, colLength := len(A), len(A[0])
result := 1 << (colLength - 1) * rowLength
for col := 1; col < colLength; col++ {
count := 0
for row := 1; row < rowLength; row++ {
if A[row][col]^A[row][0] == 1 {
count++
}
}
if count ... |
package save
import (
"context"
"encoding/json"
"fmt"
"github.com/devspace-cloud/devspace/cmd/flags"
"github.com/devspace-cloud/devspace/pkg/devspace/kubectl"
"github.com/devspace-cloud/devspace/pkg/util/factory"
"github.com/devspace-cloud/devspace/pkg/util/message"
corev1 "k8s.io/api/core/v1"
kerrors "k8s.... |
package lang
import (
"fmt"
"strconv"
"strings"
)
// ASTNode is the ancestor of all AST nodes
type ASTNode interface {
Start() Loc
String() string
isNode()
}
// AST describes all top-level statements within a script
type AST struct {
Stmts []Stmt
}
// Start returns a location that this node can be considered... |
package problem
import "math"
type IntBTree struct {
Value int
Left *IntBTree
Right *IntBTree
}
func ValidIntBst(btree *IntBTree) bool {
return validIntBst(btree, math.MinInt64, math.MaxInt64)
}
func validIntBst(btree *IntBTree, min, max int) bool {
if btree == nil {
return true
}
if btree.Value <= min |... |
package internal
import (
"fmt"
G "github.com/ionous/sashimi/game"
"github.com/ionous/sashimi/meta"
"github.com/ionous/sashimi/util/ident"
"reflect"
)
var floatType = reflect.TypeOf(float64(0))
type gameList struct {
game *GameEventAdapter // context needed for wrapping instances
path PropertyPath
ptype ... |
// 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"
"fmt"
"path/filepath"
"regexp"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/local/apps"
"chromiumos/tas... |
// 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 arcappcompat will have tast tests for android apps on Chromebooks.
package arcappcompat
import (
"context"
"time"
"chromiumos/tast/common/android/ui"
"chromi... |
package main
import "fmt"
func main() {
var n, m, l int
fmt.Scan(&n, &m, &l)
var A, B [100][100]int
for i := 0; i < n; i++ {
for j := 0; j < m; j++ {
var x int
fmt.Scan(&x)
A[i][j] = x
}
}
for i := 0; i < m; i++ {
for j := 0; j < l; j++ {
var x int
fmt.Scan(&x)
B[i][j] = x
}
}
... |
package router
import (
"encoding/json"
"net/http"
"net/http/httptest"
"os"
"testing"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/openrtb_ext"
"github.com/stretchr/testify/assert"
)
const adapterDirectory = "../adapters"
type testValidator struct{}
func (validator *testValida... |
package main
import "time"
type Interval string
const (
Hourly Interval = "hourly"
Daily Interval = "daily"
Weekly Interval = "weekly"
Monthly Interval = "monthly"
)
var Intervals = [...]Interval{Hourly, Daily, Weekly, Monthly}
func (interval Interval) CalcIndex(now time.Time, snapshotTime time.Time) int {... |
package watcher
import (
"context"
"io"
"math/big"
)
type Repo interface {
StoreTxsByBlockID(Tx) error
FindTxsByBlockID(blockID *big.Int) ([]Tx, error)
PurgeTxsByBlockID(blockID *big.Int) error
}
type Tx interface {
Sender() []byte
Receiver() []byte
ID() []byte
Amount() *big.Int
Net() string
Kind() string... |
package main
import (
"database/sql"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
_ "github.com/lib/pq"
)
type Person struct {
Admin_id int `json:"admin_id"`
Name string `json:"name"`
Username string `json:"username"`
Password string `json:"password"`
Role int `json:"role"`
}
type Pr... |
package forum
import (
//"github.com/astaxie/beego"
//"fmt"
"net/http"
"strconv"
"tripod/convert"
"tripod/timekit"
"webserver/common"
"webserver/controllers"
"webserver/models/maccount"
)
type CommentMeController struct {
controllers.BaseController
}
func (c *CommentMeController) Post() {
defer c.Recover(... |
package rod
import (
"bytes"
"context"
"encoding/base64"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"os"
"path/filepath"
"reflect"
"regexp"
"runtime/debug"
"sync"
"time"
"github.com/go-rod/rod/lib/cdp"
"github.com/go-rod/rod/lib/proto"
"github.com/go-rod/rod/lib/utils"
)
// CDPClient is usually us... |
package day12
import (
"testing"
)
func TestFull(t *testing.T) {
orbit := Orbit{}
orbit.Init()
orbit.Moons[0].X = -8
orbit.Moons[0].Y = -10
orbit.Moons[0].Z = 0
orbit.Moons[1].X = 5
orbit.Moons[1].Y = 5
orbit.Moons[1].Z = 10
orbit.Moons[2].X = 2
orbit.Moons[2].Y = -7
orbit.Moons[2].Z = 3
orbit.Moons[3].X... |
// +build gbucket
package gbucket
/*
TODO:
* (maybe) Allow creation of new bucket (using http API)
* Encode keys with random test prefix for testing
* Improve error handling (more expressive print statements)
* Refactor to call batcher for multiple DB requests. Consider multipart http requests.
Explore tradeoff betw... |
// ./design/mediatypes/task.go
package mediatypes
import (
goa "github.com/goadesign/goa/design"
dsl "github.com/goadesign/goa/design/apidsl"
)
// Task はタスクリソースのメディアタイプ
var Task = dsl.MediaType("application/x-learning-goa+json", func() {
dsl.Description("タスク")
dsl.Attributes(func() {
dsl.Attribute("id", goa.In... |
package acrostic
import "github.com/noyuno/lgo/runes"
// CaseAnalysisType : 格解析のタイプ
type CaseAnalysisType int
const (
// NoneSide : なし
NoneSide = iota
// PredicateSide : 述語側
PredicateSide
// CaseElementSide : 格要素側
CaseElementSide
)
// GetCaseAnalysisType : 格解析のタイプを取得する
// t: テキスト
// return: 格解析のタイプ
func GetCa... |
package main
import "observer"
func main() {
news := observer.News{}
zhangsan := observer.NewNewsReporter("zhangsan")
news.Focus(zhangsan)
lisi := observer.NewNewsReporter("lisi")
news.Focus(lisi)
news.Happen("someone was killed!") // zhangsan reported an event:someone was killed! lisi reported an event:som... |
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
rand.Seed(time.Now().Unix())
fmt.Println(rand.Intn(100))
start := "!"
fmt.Println(byte(start[0]))
fmt.Println(string(start[0] + byte(rand.Intn(94))))
}
|
// Copyright 2021 T-Mobile USA, 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 wri... |
package test
import (
"bytes"
"net/http"
"net/http/httptest"
"social/api/routes"
"testing"
)
// Test for the post /users request
func TestPostUser(t *testing.T){
var jsonStr = []byte(`{"_id":"569ed8269353e9f4c51617aa","name":"test","email":"test@gmail.com","password":"testPassword"}`)
req,err := http.NewReques... |
package ravendb
import (
"net/http"
"strconv"
)
var (
_ RavenCommand = &GetDocumentsCommand{}
)
type GetDocumentsCommand struct {
RavenCommandBase
_id string
_ids []string
_includes []string
_metadataOnly bool
_startWith string
_matches string
_start int
_pageSize int
_exclude str... |
package tests
import (
"testing"
)
/**
* [673] Number of Longest Increasing Subsequence
*
*
* Given an unsorted array of integers, find the number of longest increasing subsequence.
*
*
* Example 1:
*
* Input: [1,3,5,4,7]
* Output: 2
* Explanation: The two longest increasing subsequence are [1, 3, ... |
package iafon
import (
"errors"
"fmt"
"net/http"
)
type Server struct {
http.Server
// only for get methods of Router type
*Router
}
func NewServer(addr ...string) *Server {
s := &Server{}
if len(addr) > 0 {
s.Addr = addr[0]
}
s.Router = newRouter()
s.Handler = s.Router
return s
}
func (s *Server)... |
package utils
import (
"fmt"
"io"
"os"
opentracing "github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus"
"github.com/uber/jaeger-client-go"
"github.com/uber/jaeger-client-go/config"
)
var StandardLogFields log.Fields = log.Fields{
"app": "g... |
package mirror
import (
"context"
"errors"
"fmt"
"os"
"path"
"path/filepath"
"strings"
"github.com/containers/image/v5/types"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/opencontaine... |
package models
import (
"encoding/json"
// "log"
)
type PointSetting struct {
ID int64 `json:"id"`
Point_type string `json:"point_type"`
PointSettingUID string `json:"pointsettinguid"`
Constant_point float64 `json:"constant_point"`
Description string `json:"description"`
Create_at ... |
package common
import (
"time"
"net/http"
"github.com/labstack/echo"
"github.com/BeanWei/go-web-demo/model"
)
type Replyinfo struct {
ErrNo int `json:"errNo"`
MSG string `json:"msg"`
DATA *time.Time `json:"data"`
}
// SendErrJSON 错误发生时发送错误JSON
func (c echo.Context) SendErrJSON(msg string, args ...interface{})... |
package svc
import (
"github.com/go-playground/validator/v10"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
"go.mongodb.org/mongo-driver/mongo"
"go4eat-api/cry"
"go4eat-api/db"
ordersModel "go4eat-api/db/model/orders"
placesModel "go4eat-api/db/model/places"
usersModel "go4ea... |
package template
import (
"testing"
. "github.com/onsi/gomega"
)
func TestIsValidType(t *testing.T) {
RegisterTestingT(t)
Expect(IsType("zerzrze", "string")).To(BeTrue())
Expect(IsType(true, "string")).To(BeFalse())
Expect(IsType(true, "bool")).To(BeTrue())
Expect(IsType(make(map[string]int), "map[string]int... |
package acl
import (
// "fmt"
"github.com/apm-ai/datav/backend/pkg/models"
"github.com/apm-ai/datav/backend/pkg/log"
"github.com/apm-ai/datav/backend/internal/session"
"github.com/gin-gonic/gin"
)
var logger = log.RootLogger.New("logger", "acl")
func IsSuperAdmin(c *gin.Context) bool {
user := session.CurrentU... |
package main
import (
"bytes"
"fmt"
"log"
"os/exec"
"strings"
)
func main() {
log.Println("Hello this is certbot client manager")
verifyCertbotClientExistance()
cmd := exec.Command("C:\\Users\\Tharaka\\go\\src\\awesomeProject\\hello-world.exe", )
cmd.Stdin = strings.NewReader("this is email this is name")
... |
package main
import (
"fmt"
"net/http"
"github.com/gorilla/mux"
)
// make connection
// see NOTE below re role of setting header on document rendering
//
func home(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html") // sets page as text/html
fmt.Fprint(w, "<h1>This is my home ... |
// 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 firmware
import (
"context"
"regexp"
"strings"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/remote/firmware"
"chromiumos/tast/... |
package openapi
import (
"fmt"
"log"
"regexp"
"strings"
"github.com/go-openapi/loads"
"github.com/go-openapi/spec"
)
const resourceVersionRegex = "(/v[0-9]*/)"
const resourceNameRegex = "(/\\w*/)+{.*}"
const resourceInstanceRegex = "((?:.*)){.*}"
const swaggerResourcePayloadDefinitionRegex = "(\\w+)[^//]*$"
/... |
package torchprint
type pagedRequest struct {
Skip int `url:"Skip,omitempty"`
PageSize int `url:"PageSize,omitempty"`
}
|
package hangouts
// User struct
type User struct {
Type string `json:"type"`
Name string `json:"name"`
DisplayName string `json:"displayName"`
AvatarURL string `json:"avatarUrl"`
Email string `json:"email"`
}
// Message struct
type Message struct {
Name string `json:"name,omitempty"... |
package main
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"firebase.google.com/go"
"google.golang.org/api/option"
)
type AutoGenerated struct {
A []struct {
B struct {
Title string `json:"title"`
INDEX string `json:"INDEX"`
DEADEN... |
package model
import (
"testing"
"github.com/naiba/nezha/pkg/utils"
"github.com/stretchr/testify/assert"
)
func TestServerMarshal(t *testing.T) {
patterns := []string{
"asd > asd",
"asd \" asd",
"asd } asd",
}
for i := 0; i < len(patterns); i++ {
server := Server{
Name: patterns[i],
Tag: patter... |
package token
import (
"errors"
"fmt"
"time"
"github.com/dgrijalva/jwt-go"
)
// ParseTokenString gets the jwt.Token by providing it as a string
func ParseTokenString(tokenString string, signingString string) (*jwt.Token, error) {
token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {... |
/*
Copyright 2021 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 tcp
import (
"fmt"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"gotcp/tuntap"
"log"
"math/rand"
"net"
)
type TcpState int
const (
CLOSED TcpState = iota
LISTEN
SYN_RCVD
SYN_SENT
ESTAB
FIN_WAIT_1
CLOSE_WAIT
CLOSING
FINWAIT_2
TIME_WAIT
LAST_ACK
)
func (s TcpState) String... |
package sqlite
import _ "github.com/general252/EasyDarwinLib/github.com/mattn/go-sqlite3"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.