text stringlengths 11 4.05M |
|---|
/*
* Swagger Petstore
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* API version: 1.0.0
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package main
import (
"context"
"fmt"
"log"
"net/http"
"reflect"
RESTfulPolygl... |
package main
import (
"bytes"
"encoding/csv"
"fmt"
"io"
"log"
)
// csv读写逗号分隔值(csv)的文件
func main() {
var data = []string{"test", "Hello", "Go"}
var buf bytes.Buffer
// 初始化一个writer
w := csv.NewWriter(&buf)
// 写入
if err := w.Write(data); err != nil {
log.Fatal(err)
}
// 将缓存中的数据写入底层的io.Writer。要检查Flush时是... |
package models
import (
"context"
"corona/helpers"
"database/sql"
"fmt"
"github.com/lib/pq"
uuid "github.com/satori/go.uuid"
"time"
)
type (
CoronaModel struct {
Id uuid.UUID
CountryId uuid.UUID
TotalCases string
NewCases string
TotalDeaths string
NewDeaths strin... |
package k8s
import (
"context"
"time"
"github.com/ansel1/merry"
"github.com/tommy351/kubenvoy/pkg/config"
corev1 "k8s.io/client-go/informers/core/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"
// Load auth plugins
_ "k8s.io/client-go/plugin/pkg/client/auth"
)
type Client interface {
Watc... |
package objects
import "time"
type User struct {
ID uint `json:"id"`
Username string `json:"username"`
Password string `json:"password"`
Phone string `json:"phone"`
}
type UserLoginObjectRequest struct {
Username string `json:"username"`
Password string `json:"password"`
}
type UserStoreObjectReque... |
package hook
import (
"ekgo/api/lib/response"
"log"
)
type Test struct{}
func (p *Test) Before() *response.Write {
log.Println("在之前执行")
return nil
}
func (p *Test) After() {
log.Println("在之后执行")
}
|
package main
import "fmt"
//TermainlStatusReceiver prints the window/door
//status changes out to the terminal.
type TermainlStatusReceiver struct{}
//NewTermainlStatusReceiver creates a new instance
//of our terminal receiver, which writes status changes
//out to the terminal.
func NewTermainlStatusReceiver() *Term... |
package main
func canJump(nums []int) bool {
var post = len(nums) - 1
for i := len(nums) - 2; i >= 0; i-- {
if i+nums[i] >= post {
post = i
}
}
return post <= 0
}
|
// Package controllers sets up the controllers for the fleet-controller.
package controllers
import (
"context"
"github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/runtime/schema"
"github.com/rancher/fleet/internal/cmd/controller/controllers/bootstr... |
package main
import (
"errors"
"io/ioutil"
"os"
"path/filepath"
"github.com/juju/loggo"
"github.com/urfave/cli"
yaml "gopkg.in/yaml.v2"
)
var (
configFilename string
source string
destination string
debug bool
logger loggo.Logger
)
type conf struct {
Shared []string `yaml:"... |
package xin
import (
"bytes"
"strings"
)
type StringValue []byte
func (v StringValue) String() string {
return string(v)
}
func (v StringValue) Repr() string {
return "'" + strings.ReplaceAll(string(v), "'", "\\'") + "'"
}
func (v StringValue) Equal(o Value) bool {
if ov, ok := o.(StringValue); ok {
return ... |
package main
import (
"github.com/Sirupsen/logrus"
"github.com/cerana/cerana/pkg/logrusx"
"github.com/cerana/cerana/provider"
"github.com/cerana/cerana/providers/service"
flag "github.com/spf13/pflag"
)
func main() {
logrus.SetFormatter(&logrusx.JSONFormatter{})
config := service.NewConfig(nil, nil)
flag.Str... |
// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
// Package ranger implements lazy io.Reader and io.Writer interfaces.
package ranger
|
package main
import "sort"
//462. 最少移动次数使数组元素相等 II
//给你一个长度为 n 的整数数组 nums ,返回使所有数组元素相等需要的最少移动数。
//
//在一步操作中,你可以使数组中的一个元素加 1 或者减 1 。
//
//
//
//示例 1:
//
//输入:nums = [1,2,3]
//输出:2
//解释:
//只需要两步操作(每步操作指南使一个元素加 1 或减 1):
//[1,2,3] => [2,2,3] => [2,2,2]
//示例 2:
//
//输入:nums = [1,10,2,9]
//输出:16
//
//提示:
//
//n == nums... |
package html5_test
import (
"strings"
. "github.com/bytesparadise/libasciidoc/testsupport"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("verse blocks", func() {
Context("as delimited blocks", func() {
It("single-line verse with author and title and empty end line", func() {
... |
package refree
import (
"errors"
"log"
"math"
"github.com/samtholiya/virtual-ping-pong/core/game"
"github.com/samtholiya/virtual-ping-pong/core/player"
"github.com/samtholiya/virtual-ping-pong/core/result"
)
type refree struct {
playersLen int
players []player.Player
game game.Gam... |
package main
import (
"fmt"
)
// Given a string, find the length of the longest substring without repeating characters.
// Example 1:
// Input: "abcabcbb"
// Output: 3
// Explanation: The answer is "abc", with the length of 3.
// Example 2:
// Input: "bbbbb"
// Output: 1
// Explanation: The answer is "b", with t... |
package user
import (
"fmt"
"log"
"net/http"
)
type Articles struct {
ArticleId int32 `json:"article_id"`
UserId int32 `json:"user_id"`
Contents string `json:"contents"`
Published bool `json:"published"`
}
func (m *Module) HomeUser(w http.ResponseWriter, r *http.Request) {
fmt.Println("MASUK 0")
ro... |
package main
import (
"fmt"
)
func printMatrix(m [][]byte) {
for i:=0;i<len(m);i++ {
fmt.Printf("%q\n", m[i])
}
}
func fall(m [][]byte) {
n:=len(m)
for i:=n-1;i>0;i-- {
for j:=0;j<n;j++ {
if m[i-1][j] == '.' && m[i][j] == ' ' {
for k:=i;k<n && m[k][j] == ' ';k++ {
m[k-1][j] = ' '
m[k][j] = ... |
package controller
import (
"database/sql"
"encoding/csv"
"log"
"net/http"
"os"
"regexp"
"strconv"
"time"
"../model"
"github.com/gin-gonic/gin"
)
//TaskController -
type TaskController struct {
db *sql.DB
}
//New -
func New(db *sql.DB) *TaskController {
return &TaskController{
db: db,
}
}
//Registe... |
// 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 benchmark provides utilities for running Google Benchmark binaries on
// device.
package benchmark
import (
"context"
"encoding/json"
"chromiumos/tast/common/... |
package registry
import (
"context"
"fmt"
regv1 "github.com/tmax-cloud/registry-operator/api/v1"
cmhttp "github.com/tmax-cloud/registry-operator/internal/common/http"
"github.com/tmax-cloud/registry-operator/internal/schemes"
"github.com/tmax-cloud/registry-operator/internal/utils"
"github.com/tmax-cloud/regis... |
// Copyright (c) 2019, Arm Ltd
package main
import (
"github.com/golang/glog"
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
)
func check(err error) {
if err != nil {
glog.Errorf(err.Error())
}
}
func getDevices(n uint) []*pluginapi.Device {
var devs []*pluginapi.Device
for i := uint(0); i ... |
package carmaclient
import (
"encoding/json"
"errors"
"fmt"
"github.com/moonwalker/carmaclient/dto"
"net/http"
"net/url"
)
type ListsService service
func (s *ListsService) GetContact(listID int64, originalID string) (*dto.ContactDTO, error) {
response := s.client.carmaRequest(fmt.Sprintf("lists/%d/contacts/%s... |
package business
import (
"context"
"errors"
"main/core/models"
"time"
"github.com/pascaldekloe/jwt"
"go.mongodb.org/mongo-driver/mongo"
"golang.org/x/crypto/bcrypt"
)
type AuthBusiness struct {
DB *mongo.Database
signer *jwt.HMAC
}
func NewAuthBusiness(DB *mongo.Database, key string) (*AuthBusiness, e... |
package disassembler
import (
"fmt"
"os"
"strings"
)
var instructions map[byte]string = map[byte]string{
// nothing
0x00: "NOP", 0x10: "NOP", 0x08: "NOP", 0x18: "NOP",
0x20: "NOP", 0x30: "NOP", 0x28: "NOP", 0x38: "NOP",
// decimal adjust halt
0x27: "DAA", 0x76: "HLT",
// databus out in
0xd3: "... |
package batch
import (
"github.com/utahta/momoclo-channel/api"
"github.com/utahta/momoclo-channel/config"
)
func init() {
config.MustLoad("config/deploy.toml")
s := api.NewBatchServer()
s.Handle()
}
|
package main
import (
"net/http"
"os"
"time"
"github.com/iatistas/dolista-safado/service"
"github.com/sirupsen/logrus"
)
const noToken = "no-token"
func main() {
telegramToken := os.Getenv("TELEGRAM_TOKEN")
if telegramToken == "" || telegramToken == noToken {
logrus.Error("telegram token not provided")
... |
// Copyright 2019 - 2022 The Samply Community
//
// 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 typgo_test
import (
"os"
"testing"
"github.com/stretchr/testify/require"
"github.com/typical-go/typical-go/pkg/typgo"
)
func TestDotEnv(t *testing.T) {
os.WriteFile(".env", []byte("key1=value1\nkey2=value2\n"), 0777)
defer os.Remove(".env")
m, err := typgo.DotEnv(".env").EnvLoad()
require.NoError(t,... |
/*
Adapted from
https://github.com/kubernetes/kubectl/tree/master/pkg/cmd/apply
*/
/*
Copyright 2014 The Kubernetes 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.o... |
/*
Copyright 2011 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 to in writing, software
di... |
type Controller struct {
workqueue workqueue.RateLimitingInterface
}
func Start() {
stopCh := signals.SetupSignalHandler()
cfg, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfig)
if err != nil {
klog.Fatalf("Error building kubeconfig: %s", err.Error())
}
controller := &Controller{
workqueue: work... |
package sshutil
import (
"testing"
)
func TestCleanName(t *testing.T) {
if cleanName(" ") != "\\ " {
t.Errorf("Expected \" to be escaped")
}
}
|
package metadata
// MetaData :
type MetaData struct {
ClientName string
ClientIP string
} |
package main
import (
"fmt"
"log"
"math"
"regexp"
"strings"
"github.com/henkman/liberprimus"
"github.com/henkman/liberprimus/gematriaprimus"
)
func xor(dst, src []uint) {
for i, _ := range dst {
dst[i] ^= src[i%len(src)]
}
}
func frombase(s string, base uint, digits string) (uint, error) {
var e, n uint... |
// Copyright 2018 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
package cmd
import (
"fmt"
"log"
"os"
"syscall"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal"
"github.com/highfi... |
package utils
import "fmt"
// ConvertEnvVars convert ENV vars from a map to a list of strings in the format ["key1=val1", "key2=val2", "key3=val3" ...]
func ConvertEnvVars(envVarsMap map[any]any) []string {
res := []string{}
for k, v := range envVarsMap {
res = append(res, fmt.Sprintf("%s=%s", k, v))
}
return ... |
// date: 2019-03-15
package itf
import "github.com/Jarvens/Exchange-Agent/cache"
type Cache interface {
//查询缓存值 key
Get(k string) ([]byte, error)
//设置缓存 key-value
Set(k string, v []byte) error
//删除缓存 key
Del(k string) error
GetStat() cache.Stat
}
|
package gorm2
import (
"context"
"errors"
"testing"
"time"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/traPtitech/trap-collection-server/src/domain"
"github.com/traPtitech/trap-collection-server/src/domain/values"
"github.com/traPtitech/trap-collection-server/src/repository"
"g... |
package storage
import "gitlab.cheppers.com/devops-academy-2018/shop2/pkg/shoe/model"
type Handler interface {
Insert(p model.Shoe) (model.Shoe, error)
Read(id uint) model.Shoe
Update(p model.Shoe, fields map[string]interface{}) (model.Shoe, error)
Delete(id uint) error
List() []model.Shoe
Count() int
}
|
package parser_test
import (
"strings"
"github.com/bytesparadise/libasciidoc/pkg/parser"
"github.com/bytesparadise/libasciidoc/pkg/types"
. "github.com/bytesparadise/libasciidoc/testsupport"
log "github.com/sirupsen/logrus"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("tables",... |
package usersNMethods
import (
"database/sql"
"fmt"
"time"
)
func AddUser(ID int, FirstName string, LastName string, Email string, Sex int, Date time.Time, Loan float64) {
Db, err := sql.Open("postgres", "user=postgres password=root dbname=Technorely sslmode=disable")
if err != nil {
panic(err)
}
defer Db.Cl... |
// 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 local
type Config struct {
Path string `yaml:"path"`
}
|
package main
import (
"github.com/nsf/termbox-go"
"turbot/gdb"
"turbot/viz"
)
type CodeView struct {
win *viz.Window
mainWin *viz.Window
title *viz.TitleView
files *FilesView
source *SourceView
}
func MakeCodeView(win *viz.Window) *CodeView {
titleWin, mainWin := win.SplitV(-1)
me := &CodeView{
wi... |
package migration
import (
"testing"
)
func TestConvert(t *testing.T) {
const (
testData = "otpauth-migration://offline?data=CjEKCkhlbGxvId6tvu8SGEV4YW1wbGU6YWxpY2VAZ29vZ2xlLmNvbRoHRXhhbXBsZTAC"
want = "otpauth://totp/Example:alice@google.com?issuer=Example&period=30&secret=JBSWY3DPEHPK3PXP"
)
p, err := U... |
package canvasapi
import (
"fmt"
"net/http"
"net/url"
"regexp"
"strconv"
"strings"
)
var resourceRegex = regexp.MustCompile(`<(.*?)>; rel="(.*?)"`)
type PagedResource struct {
Current, First, Last, Next *PagedLink
}
type PagedLink struct {
URL *url.URL
Page int
}
func ExtractPagedResource(header http.Hea... |
package parlaytypes
import (
"encoding/json"
)
// TreasureMap - X Marks the spot
// The treasure maps define the automation that will take place on the hosts defined
type TreasureMap struct {
// An array/list of deployments that will take places as part of this "map"
Deployments []Deployment `json:"deployments"`
}... |
package api
import (
"database/sql"
"net/http"
log "github.com/Sirupsen/logrus"
restful "github.com/emicklei/go-restful"
"github.com/gatorloopwebapp/database"
)
// CalculatedAcceleration : struct to hold calculated acceleration values
type CalculatedAcceleration struct {
Val float64 `json:"acceleration"`
}
//... |
package odoo
import (
"fmt"
)
// AccountInvoiceConfirm represents account.invoice.confirm model.
type AccountInvoiceConfirm struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
DisplayName *S... |
// 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 tests
import (
"fmt"
"testing"
"github.com/ravendb/ravendb-go-client"
"github.com/stretchr/testify/assert"
)
type Family struct {
Names []string
}
type FamilyMembers struct {
Members []*Member
}
type Member struct {
Name string
Age int
}
type Arr1 struct {
Str []string
}
type Arr2 struct {
Arr... |
package main
import (
"fmt"
)
type IntMap map[int]int
func makerange(start, end int) []int {
r := []int{}
for i := start; i <= end; i++ {
r = append(r, i)
}
return r
}
func get_factors(n int) IntMap {
rslt := make(IntMap)
for i := range makerange(2, 20) {
rslt[i] = 0
... |
package main
import (
"bufio"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"path"
"path/filepath"
"regexp"
"strings"
)
const cdbPath string = `C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\cdb.exe`
const cdbCommand string = "!analyze -v;q"
const version = "v0.0.3c"
const ok = 0
const dmpNotFound =... |
// server_01
package main
import (
"fmt"
"net/http"
"strconv"
"strings"
)
//another service
func GetServiceThree(w http.ResponseWriter, r *http.Request) {
//en := json.NewEncoder(fp)
url := r.URL.Path
urlArray := strings.Split(url, "/")
parameterArray := strings.Split(urlArray[2], " ")
ans := 0
for i := 0... |
package imageregistrybinding
import (
"log"
"alauda.io/devops-apiserver/pkg/apis/devops/v1alpha1"
devopsclient "alauda.io/devops-apiserver/pkg/client/clientset/versioned"
"alauda.io/diablo/src/backend/api"
"alauda.io/diablo/src/backend/errors"
"alauda.io/diablo/src/backend/resource/common"
"alauda.io/diablo/sr... |
// 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 main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
)
// Person is simple structure
type Person struct {
Firstname, Lastname, Tel string
Age int
}
func loadFromJSON(filename string, v interface{}) error {
file, err := os.Open(filename)
defer file.Close()
if err != nil {
... |
package __ComplexType
import . "_ImportLocation"
func First(slice []_ComplexType) (res _ComplexType) {
if len(slice) == 0 {
return
}
res = slice[0]
return
}
func (c *chain) First() *chain {
return &chain{value: []_ComplexType{First(c.value)}}
} |
//
// 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
// distribu... |
/*
* @lc app=leetcode id=59 lang=golang
*
* [59] Spiral Matrix II
*
* https://leetcode.com/problems/spiral-matrix-ii/description/
*
* algorithms
* Medium (54.07%)
* Likes: 1106
* Dislikes: 119
* Total Accepted: 202K
* Total Submissions: 372K
* Testcase Example: '3'
*
* Given a positive integer n, ... |
package main
import (
"bufio"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"runtime"
"strconv"
"github.com/mitchellh/go-homedir"
)
var (
ug = "0:0"
version = "0.0.0"
build = "-"
owner = "appcelerator"
repo = "github.com/appcelerator/amp"
dockerCm... |
package instances
import (
"context"
"fmt"
"github.com/exoscale/egoscale"
"github.com/janoszen/exoscale-account-wiper/plugin"
"log"
"sync"
"time"
)
type Plugin struct {
}
func (p *Plugin) GetKey() string {
return "instances"
}
func (p *Plugin) GetParameters() map[string]string {
return make(map[string]stri... |
package tracing
import (
"context"
"errors"
"fmt"
"math"
"net/http"
"os"
"runtime"
"strings"
"github.com/rs/zerolog"
otelContrib "go.opentelemetry.io/contrib/propagators/jaeger"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/exp... |
/*
MIT License
Copyright (c) 2018 IBM
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute... |
// Copyright 2019 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 tq
import (
"fmt"
"hash"
"io"
"os"
"path/filepath"
"regexp"
"strconv"
"github.com/git-lfs/git-lfs/errors"
"github.com/git-lfs/git-lfs/localstorage"
"github.com/git-lfs/git-lfs/tools"
"github.com/rubyist/tracerx"
)
// Adapter for basic HTTP downloads, includes resuming via HTTP Range
type basicDown... |
package main
import "fmt"
type ListNode struct {
Val int
Next *ListNode
}
func (l *ListNode) Print() {
if l == nil {
fmt.Print("NULL\n")
return
}
fmt.Print(l.Val, "->")
l.Next.Print()
}
func partition(head *ListNode, x int) *ListNode {
nhead := []*ListNode{nil, nil}
nnow := []*ListNode{nil, nil}
now :=... |
package network
import (
"fmt"
"github.com/woobest/network/config"
)
const PacketHeadSize = 6
var ErrorPacketError = fmt.Errorf("Packet error")
type NetPacket struct {
BodySize uint16
Opcode uint32
}
func (self *NetPacket) PrasePacket(buf []byte) error {
self.BodySize = config.ByteOrder.U... |
package clientkube
import (
"github.com/go-logr/logr"
"github.com/go-logr/logr/testing"
"github.com/bryanl/clientkube/pkg/cluster"
)
type options struct {
logger logr.Logger
store cluster.Store
}
func currentOptions(list ...Option) options {
opts := options{
logger: &testing.NullLogger{},
}
for _, o := ... |
package source
import (
"errors"
"fmt"
"io"
"net/http"
"net/url"
"regexp"
"strings"
log "github.com/sirupsen/logrus"
"github.com/sp0x/surf/browser"
"github.com/sp0x/surf/jar"
)
const (
searchMethodPost = "post"
searchMethodGet = "get"
)
type WebClient struct {
Browser browser.Browsable
Cacher ... |
package testxuzan
import "fmt"
func Xuzan() {
fmt.Println(222222222)
}
|
// 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 models
import(
"encoding/json"
)
/**
* Type definition for SeverityEnum enum
*/
type SeverityEnum int
/**
* Value collection for SeverityEnum enum
*/
const (
Severity_KCRITICAL SeverityEnum = 1 + iota
Severity_KWARNING
Severity_KINFO
)
func (r SeverityEnum) MarshalJSO... |
package main
import "github.com/spf13/cobra"
type clusterAnnotationAddFlags struct {
clusterFlags
cluster string
annotations []string
}
func (flags *clusterAnnotationAddFlags) addFlags(command *cobra.Command) {
command.Flags().StringVar(&flags.cluster, "cluster", "", "The id of the cluster to be annotated.")... |
package main
import (
"fmt"
"kcctoken"
"log"
"math/big"
"os"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
)
func _transfer(_addr string, _num int64) {
cli, err := ethclient.Dial("http://localhost:8545")
if err != ni... |
package postgres
import (
"context"
"github.com/stone-co/the-amazing-ledger/app/domain/vos"
"github.com/stone-co/the-amazing-ledger/app/shared/instrumentation/newrelic"
)
func (r *LedgerRepository) GetAnalyticalData(ctx context.Context, path vos.AccountPath, fn func(vos.Statement) error) error {
operation := "Re... |
package tasks
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-swagger/go-swagger/httpkit"
"github.com/go-swagger/go-swagger/examples/task-tracker/models"
)
/*UpdateTaskOK Task details
swagger... |
// This file was generated by counterfeiter
package fakes
import (
"database/sql"
"sync"
)
type Db struct {
ExecStub func(query string, args ...interface{}) (sql.Result, error)
execMutex sync.RWMutex
execArgsForCall []struct {
query string
args []interface{}
}
execReturns struct {
result1 s... |
package main
import (
"fmt"
"os"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/sp0x/torrentd/indexer"
"github.com/sp0x/torrentd/indexer/search"
"github.com/sp0x/torrentd/indexer/status"
)
func init() {
cmdGet := &cobra.Command{
Use: "get",
Short: "Run ... |
package main
func f()
|
package controllers
import (
"fmt"
"net/http"
"github.com/astaxie/beego"
"github.com/go-react/community/models"
)
// ErrorController 提供统一的错误处理控制器
type ErrorController struct {
BaseController
}
// result 响应错误结果
func (ec *ErrorController) result(statusCode int, message string) {
result := models.C_ErrorResult{
... |
package models
import "time"
// TODO(nick): Shared protobuf would be nice
type Sms struct {
Address string `json:"address"`
Body string `json:"body"`
Date time.Time `json:"date"`
ID int64 `json:"id,omitempty"`
ThreadID string `json:"threadId"`
SmsType int `json:"type"`
}
|
/*
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 repository
import (
"fmt"
"github.com/jmoiron/sqlx"
"github.com/solntsevatv/url_translater/internal/url_translater"
)
type UrlPostgres struct {
db *sqlx.DB
}
func NewUrlPostgres(db *sqlx.DB) *UrlPostgres {
return &UrlPostgres{db: db}
}
func (r *UrlPostgres) IsDBEmpty() (bool, error) {
var count int
... |
// date: 2019-03-12
package log
import (
"github.com/Jarvens/Exchange-Agent/util/config"
"github.com/sirupsen/logrus"
"gopkg.in/natefinch/lumberjack.v2"
"net/http"
"os"
)
func LumberJackLogger(filePath string, maxSize int, maxBackups int, maxAge int) *lumberjack.Logger {
return &lumberjack.Logger{Filename: file... |
// +build storage_pgx
package config
const DefaultStorage = StoragePostgres
|
package main
import (
"fmt"
"log"
"net/http"
"os"
"time"
)
func handler(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
name := query.Get("name")
if name == "" {
name = "Guest"
}
log.Printf("Received request for %s\n", name)
w.Write([]byte(fmt.Sprintf("Welcome, %s\n", name)))
}
func mai... |
package collect
import (
"archive/tar"
"bytes"
"context"
"io"
"os"
"path/filepath"
"time"
"github.com/pkg/errors"
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
"github.com/replicatedhq/troubleshoot/pkg/logger"
"github.com/segmentio/ksuid"
appsv1 "k8s.io/api/apps/... |
package worker
import (
"github.com/winjeg/db-filler/config"
"github.com/winjeg/db-filler/log"
"github.com/winjeg/db-filler/schema"
"github.com/winjeg/db-filler/store"
"fmt"
"sync"
)
var (
conf = config.GetConf()
logger = log.GetLogger()
db = store.GetDb()
wg = sync.WaitGroup{}
)
func logError(e... |
package main
import (
"github.com/urfave/cli"
)
var configCommand = cli.Command{
Name: "config",
HelpName: "config",
Usage: `View and edit client configuration`,
Description: `With this command you view and edit the client configurations
like ndoe address, username, namespace, etc.`,
ArgsUsage: "eli co... |
package tmpl
import "bytes"
import "testing"
func testWrite(t *testing.T, root *fsRoot, name, value string) {
target, err := root.Writer(name)
if err != nil {
t.Fatal("could not create writer", err)
}
if _, err := target.Write([]byte(value)); err != nil {
t.Fatal("could not write", value)
}
}
func testRead(... |
package base91
import(
"fmt"
"unicode/utf8"
)
var encodeTable []byte
var decodeTable []byte
var ebq, en, dbq, dn, dv int
// Init Initializes the arrays used for conversion
func Init(){
encodeTable=StringToASCIIBytes("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~\"")
d... |
package main
import "fmt"
func main() {
for i := 1; i <= 10000; i++ {
fmt.Printf("\t %v", i)
} //END for
} //END main
//Hands-on exercise #1
//Print every number from 1 to 10,000
//solution: https://play.golang.org/p/voDiuiDGGw
//video: 050
//SOLUTION: (The solution starts at 0)
//package main
//import (
//... |
package adapter
import (
"bytes"
"fmt"
"git.trac.cn/nv/subscribe/pkg/db"
"git.trac.cn/nv/subscribe/pkg/logging"
"gopkg.in/ini.v1"
"os"
)
func Surge() ([]byte, error) {
var (
err error
cfg *ini.File
)
nodes, err := db.GetTrojanNodes(map[string]interface{}{"is_deleted": 0})
if err != nil {
logging.Error... |
package model
import "fmt"
type Config struct {
MySQL *MySQLOptions `yaml:"MYSQL"`
PostgreSQL *PostgreSQLOptions `yaml:"POSTGRESQL"`
}
type MySQLOptions struct {
Host string `yaml:"HOST"`
Port string `yaml:"PORT"`
User string `yaml:"USER"`
Pass string `yaml:"PASS"`
Db string `yaml:"... |
package tests
import "fmt"
/*
Example functionsはExampleから始まる名前で定義し、
出力を// Output:から始まるコメントで書くことで、標準出力の内容をテストできる。
もし、Outputのコメントがない場合にはコンパイルのみが走る。
*/
func ExampleHello() {
fmt.Println("Hello")
// Output: Hello
}
/*
Unordered outputoを使うと、順不同な結果に対してもマッチさせることができる。
例えば、mapをイテレートすると順不同に結果が返ってくるので、そういったケースで使用する。
*/
func ... |
package main
import (
"encoding/json"
"fmt"
"os"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
// HandleRequest handles an API Gateway proxy request
func HandleRequest(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
// Capture the 'name' query p... |
/*
Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head.
For example,
Given linked list: 1->2->3->4->5, and n = 2.
After removing the second node from the end, the linked list becomes 1->2->3->5.
Note:
Given n will always be valid.
Try to do this in on... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.