text stringlengths 11 4.05M |
|---|
package addressmap
import (
"github.com/cocher/utils/log"
"github.com/cocher/network"
"github.com/cocher/peer"
)
type Component struct {
*network.Component
MappingAddress string
}
var (
// ComponentID to reference address mapping Component
ComponentID = (*Component)(nil)
_ ... |
package main
import (
"context"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/webdevops/go-common/prometheus/collector"
"go.uber.org/zap"
devopsClient "github.com/webdevops/azure-devops-exporter/azure-devops-client"
)
type MetricsCollectorStats struct {
collector.Processor
prometheus ... |
package main
import (
"github.com/arstercz/go-mysql/replication"
"github.com/siddontang/go-mysql/mysql"
"github.com/siddontang/go-mysql/client"
"golang.org/x/net/context"
"github.com/arstercz/goconfig"
_ "github.com/davecgh/go-spew/spew"
"os"
"regexp"
"time"
"flag"
"fmt"
"strings"
)
type SQLInfo struct {
... |
package ui
import (
"image"
)
// Group is a container of more components, similar to a transparent Window
type Group struct {
component
}
// NewGroup creates a new Group
func NewGroup(width, height int) *Group {
grp := Group{}
grp.backgroundColor = Transparent
grp.Dimension.Width = width
grp.Dimension.Height =... |
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
//
package utility
import (
"encoding/base64"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"os"
"strings"
"github.com/mattermost/mattermost-cloud/internal/tools/helm"
"github.com/mattermost/ma... |
package cicd
import (
"fmt"
"net/http"
platformK8s "github.com/dolittle/platform-api/pkg/platform/k8s"
"github.com/dolittle/platform-api/pkg/utils"
"github.com/gorilla/mux"
"github.com/sirupsen/logrus"
)
type service struct {
logContext logrus.FieldLogger
k8sDolittleRepo platformK8s.K8sPlatformRepo
}
f... |
/*
pod-connector is a Command Line Interface tool for querying a local sentinel
config file or a Red Skull sentinel management server for a given pod's
configuration.
It can optionally be used to launch redis-cli to connect to a pod given the pod
name.
*/
package main
|
// Copyright 2018 Saferwall. All rights reserved.
// Use of this source code is governed by Apache v2 license
// license that can be found in the LICENSE file.
// Package gib implements a gibberish string evaluator.
package gib
import (
"errors"
"math"
"strings"
)
const (
// MinLength represents minimal length o... |
package main
import "fmt"
func main() {
//unlike Java, you don't need a break statement --
//once a matching case is found, it will break
switch signal := 1; signal {
case 0:
fmt.Println("reg")
case 1:
fmt.Println("orange")
case 2:
fmt.Println("green")
}
var score int = 63
switch {
case s... |
package odoo
import (
"fmt"
)
// FormatAddressMixin represents format.address.mixin model.
type FormatAddressMixin struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
}
// FormatAddressMixins represents ... |
package main
import (
"errors"
"log"
"math/rand"
"sort"
"time"
)
func randomArray(length int, maxInteger int) (randAry []int, err error) {
if length == 0 || maxInteger == 0 {
return randAry, errors.New("length or maxIntegr can not be zero")
}
rand.Seed(time.Now().UnixNano())
for i := 1; i < length; i++ {
... |
package main
import (
"flag"
"log"
"github.com/benbjohnson/megajson/generator"
)
func init() {
log.SetFlags(0)
}
func main() {
flag.Parse()
if flag.NArg() == 0 {
usage()
}
path := flag.Arg(0)
g := generator.New()
if err := g.Generate(path); err != nil {
log.Fatalln(err)
}
}
func usage() {
log.Fata... |
package model
type TaggedData struct {
Tag string `json:"tag"`
}
|
// Package report outlines how reports are formatted and validated
package report
import (
"encoding/json"
"github.com/UnityTech/nemesis/pkg/cis"
"github.com/golang/glog"
)
const (
// Failed indicates that a resource did not match expected spec
Failed = "failed"
// Passed indicates that a resource met the exp... |
package config
import (
"encoding/json"
"errors"
"testing"
"github.com/prebid/go-gdpr/consentconstants"
"github.com/prebid/prebid-server/openrtb_ext"
"github.com/stretchr/testify/assert"
)
func TestAccountGDPREnabledForChannelType(t *testing.T) {
trueValue, falseValue := true, false
tests := []struct {
de... |
package mediator
import (
"context"
)
type Pipeline struct {
behaviours []BehaviorFunc
pipeline PipelineFunc
handlers map[string]RequestHandler
}
func New() *Pipeline {
return &Pipeline{
handlers: make(map[string]RequestHandler),
}
}
func (p *Pipeline) UseBehaviour(behaviour PipelineBehaviour) Builder... |
package iotmaker_platform_IDraw
import (
iotmakerPlatformTextMetrics "github.com/helmutkemper/iotmaker.santa_isabel_theater.platform.textMetrics"
"github.com/helmutkemper/iotmaker.santa_isabel_theater.platform.webbrowser/browserMouse"
"github.com/helmutkemper/iotmaker.santa_isabel_theater.platform.webbrowser/font"
... |
package main
import (
"fmt"
"github.com/summerKK/leetcode-Go/algs4/cmd/1.3"
)
/**
1.3.6
下面这段代码对队列 q 进行了什么操作?
Stack<String> stack = new Stack<String>();
while (!q.isEmpty())
stack.push(q.dequeue());
while (!stack.isEmpty())
q.enqueue(stack.pop());
*/
func main() {
S := &__3... |
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"gopkg.in/bblfsh/client-go.v1"
"gopkg.in/bblfsh/sdk.v1/uast"
)
var (
serverAddr string
filename string
language string
out string
)
func main() {
flag.StringVar(&serverAddr, "addr", ":9432", "bblfsh server endpoint")
flag.S... |
package cmd
import (
"github.com/fugue/fugue-client/client/families"
"github.com/spf13/cobra"
)
// NewDeleteFamilyCommand returns a command that deletes a family
func NewDeleteFamilyCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "family [family_id]",
Short: "Deletes a family",
Args: cobra.ExactAr... |
package install
import (
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
platform "kolihub.io/koli/pkg/apis/core/v1alpha1"
)
func init() {
platform.PlatformRegisteredRoles = []platform.PlatformRole{
platform.RoleAttachAllow,
platform.RoleAutoScaleAllow,
platform.RoleExecAllow,
platform.RolePor... |
package main
import "fmt"
// nested struct || embedded struct
type shapeProps struct {
x int
y int
}
// struct is a way to describe the data and data types.
type shape struct {
boldBorders bool
area int
shapeProps shapeProps
// only "shapeProps" reduces "shapeProps shapeProps" AKA shorthand like so:
... |
package request
// AddCompanyRequest ...
type AddCompanyRequest struct {
CompanyName string `json:"companyName" validate:"required"`
Logo string `json:"logo"`
Description string `json:"description" `
Website string `json:"website"`
Established string `json:"established"`
NoOfEmployees int64 ... |
package openrtb_ext
// ExtImpTriplelift defines the contract for bidrequest.imp[i].ext.prebid.bidder.triplelift
type ExtImpTriplelift struct {
InvCode string `json:"inventoryCode"`
Floor *float64 `json:"floor"`
}
|
package common
import (
"strings"
"os/exec"
"runtime"
"fmt"
)
func runInWindows(cmd string) (string, error) {
result, err := exec.Command("cmd", "/c", cmd).Output()
if err != nil {
return "", err
}
return strings.TrimSpace(string(result)), err
}
func RunCommand(cmd string) (string, error) {
if runtime.GOO... |
package leetcode_go
import (
"sort"
)
func subsets(nums []int) [][]int {
sort.Ints(nums)
res := [][]int{[]int{}}
for _, num := range nums {
toAdd := [][]int{}
for _, set := range res {
new := append(append([]int{}, set...), num)
toAdd = append(toAdd, new)
}
res = append(res, toAdd...)
}
return res... |
/*
* Sieve of Eratosthenes in Go
*
* some minor optimization, see comments in sieve()
* each number cost 1 bit in isprime memory
*
* fast enough
*
* some bit manipulation, time enclapsed, etc.
*
*
* SideNote:
*
* if you want super fast prime generator, check out
* http://cr.yp.to/primegen.html
* which us... |
// Copyright 2019 The Berglas 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 agre... |
package appErrors
import (
"net/http"
)
type ErrorResponse struct {
Status int `json:"status"`
Message string `json:"message"`
Details interface{} `json:"details,omitempty"`
}
func (e ErrorResponse) Error() string {
return e.Message
}
func (e ErrorResponse) StatusCode() int {
return e.Status
}
... |
package scraper
type Scraper interface {
Name() string
Scrape() error
Categories() []Category
Products() []Product
Validate() error
HomepageURL() string
Currency() string
}
type Category struct {
Name string `json:"name"`
URL string `json:"url"`
}
type Product struct {
Name string `json:"name"`
P... |
package loglevel
const (
NotSet LogLevel = 0
Trace LogLevel = 10
Debug LogLevel = 20
Info LogLevel = 30
Warning LogLevel = 40
Error LogLevel = 50
Fatal LogLevel = 60
System LogLevel = 100
)
type LogLevel int
func (l LogLevel) String() string {
var name string
switch l {
case NotSet:
name = ... |
package openhab
import (
"bytes"
"fmt"
"net/http"
"strings"
)
type OpenHabCommunicator struct{
}
func (*OpenHabCommunicator) ListItems() (*[]Item, error){
c := NewClient("")
req, err := http.NewRequest("GET", fmt.Sprintf("%s/items", c.BaseURL), nil)
if err != nil {
return nil, err
}
res := [] Item{}
... |
package memio
import (
"io"
"unicode/utf8"
)
// String grants a string Read-Only methods.
type String string
// Read satisfies the io.Reader interface
func (s *String) Read(p []byte) (int, error) {
if len(p) == 0 {
return 0, nil
}
if len(*s) == 0 {
return 0, io.EOF
}
n := copy(p, *s)
*s = (*s)[n:]
retur... |
/*
Let's conclude this section by writing one more program.
This program will perform the same operations on each element of a slice and return the result.
For example if we want to multiply all integers in a slice by 5 and return the output,
it can be easily done using first class functions.
These kind of functions wh... |
package lang
import (
"testing"
)
func TestPeekTokenIsNot(t *testing.T) {
expectTokenToMatch := func(source string, tests ...tokType) {
p := makeParser("", source)
got := p.peekTokenIsNot(tests[0], tests[1:]...)
if got != false {
t.Errorf("Expected %t, got %t\n", false, got)
}
}
expectTokenToNotMatch... |
package main
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"path"
)
type Builder struct {
TopologyPath string
EnvironmentPath string
DeploymentPath string
Topology Topology
Environment Environment
}
func NewBuilder(topologyPath string, environmentPath string) *Builder {
return &Builder... |
package mci
import (
"database/sql"
"fmt"
"os"
"path/filepath"
"strings"
"time"
"github.com/bingoohuang/gonet"
"github.com/bingoohuang/gou/pbe"
"github.com/bingoohuang/sqlx"
"github.com/jinzhu/gorm"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
func (s Settings) resetMySQCluster() error {
s.cu... |
package main;
import (
"os"
"fmt"
"path"
"strings"
"bpmerror"
)
type LsCommand struct {
BpmModuleName string
}
func (cmd *LsCommand) Name() string {
return "ls"
}
func (cmd *LsCommand) IndentAndPrintTree(indentLevel int, mytext string){
text := "|"
for i := 0; i < indentLevel; i+... |
package endpoint
import (
"github.com/gin-gonic/gin"
"hospital-go/config"
"hospital-go/model"
"hospital-go/util"
"net/http"
)
type Auth struct {
Email string `json:"email"`
Password string `json:"password"`
}
func Login(c *gin.Context) {
var json Auth
if err := c.ShouldBindJSON(&json); err != nil {
c.J... |
// Copyright (C) 2018 Satoshi Konno. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package echonet
import (
"fmt"
)
const (
DeviceOperatingStatus = ObjectOperatingStatus
DeviceInstallationLocation ... |
package v1alpha1
import (
"fmt"
"github.com/kotalco/kotal/apis/shared"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// SwarmSpec defines the desired state of Swarm
type SwarmSpec struct {
// Nodes is swarm nodes
// +kubebuilder:validation:MinItems=1
Nodes []Node `json:"nodes"`
}
// Node is ipfs node
type N... |
package main
import "fmt"
func main() {
fmt.Println("myString"[2]) //puedes coger el indice de una string, y te devolvera su valor numerico
fmt.Println(string("myString"[2])) // lo mismo que antes pero convertido a string
fmt.Println("쯼"[0]) //este caracter esta compuesto por 3 bytes, [236 1... |
package common
// Checksum will calculate the checksum of a byte slice.
func Checksum(b []byte) uint16 {
sum := uint32(0)
for ; len(b) >= 2; b = b[2:] {
b0 := uint32(b[0])
b1 := uint32(b[1])
sum += (b0 << 8) | b1
}
if len(b) > 0 {
sum += uint32(b[0]) << 8
}
for sum > 0xFFFF {
sum = (sum >> 16) + (sum &... |
package main
import (
"bytes"
"context"
"crypto/sha512"
"errors"
"flag"
"fmt"
"io"
"net/url"
"os"
"sync"
"github.com/folbricht/desync"
)
const untarUsage = `desync untar <catar> <target>
Extracts a directory tree from a catar file or an index file.`
func untar(ctx context.Context, args []string) error {... |
/*
Copyright 2019 Adobe
All Rights Reserved.
NOTICE: Adobe permits you to use, modify, and distribute this file in
accordance with the terms of the Adobe license agreement accompanying
it. If you have received this file from a source other than Adobe,
then your use, modification, or distribution of it requires the pri... |
package main
import (
"fmt"
"time"
)
//We often want to execute Go code
// at some point in the future, or repeatedly at some interval.
func main() {
//Timers represent a single event in the future. You tell the timer how long you want to wait,
timer1 := time.NewTimer(2 * time.Second)
<-timer1.C
fmt.Println("T... |
package struct_utils
import (
"regexp"
"strings"
"github.com/chenwj93/utils"
"fmt"
)
var reg =`delete[\s]+from[\s]+([-_a-zA-Z0-9]+)[\s]+|delete[\s]+([-_a-zA-Z0-9]+)[\s]+|update[\s]+([-_a-zA-Z0-9]+)[\s]+|insert[\s]+into[\s]+([-_a-zA-Z0-9]+)[\s]+|insert[\s]+([-_a-zA-Z0-9]+)[\s]+`
var r *regexp.Regexp
func init() ... |
package processd
import (
"net/http"
"strings"
"github.com/felixge/fgprof"
"github.com/gorilla/mux"
"github.com/minotar/imgd/pkg/skind"
"github.com/minotar/imgd/pkg/util/route_helpers"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
// routes regis... |
// 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 (
"database/sql"
"flag"
"fmt"
"gopkg.in/cheggaaa/pb.v1"
"io/ioutil"
"log"
"net/http"
"strings"
"sync"
)
var (
url = flag.String("url", "https://loripsum.net/api/10000/long/plaintext", "URL")
count = flag.Int("count", 1000, "fill requests count")
)
const (
INSERT_QUERY = `
begin;
... |
// 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 cryptohome
import (
"context"
"time"
uda "chromiumos/system_api/user_data_auth_proto"
cryptohomecommon "chromiumos/tast/common/cryptohome"
"chromiumos/tast/com... |
package leetcode
func containsNearbyAlmostDuplicate(nums []int, k int, t int) bool {
if len(nums) <= 1 {
return false
}
if k <= 0 {
return false
}
n := len(nums)
for i := 0; i < n; i++ {
count := 0
for j := i + 1; j < n && count < k; j++ {
if abs(nums[i]-nums[j]) <= t && j != i {
return true
}
... |
package main
// Leetcode 129. (medium)
func sumNumbers(root *TreeNode) int {
return recursiveSumNumbers(root, 0, 0)
}
func recursiveSumNumbers(root *TreeNode, cur int, res int) int {
if root == nil {
return res
}
cur = cur*10 + root.Val
if root.Left == nil && root.Right == nil {
res = res + cur
} else {
r... |
package s_logger
import (
"github.com/stretchr/testify/assert"
"sync"
"testing"
)
func TestName(t *testing.T) {
logger := New()
logger.Info("Info")
logger.Error("Error")
defer logger.Sync()
assert.NotEmpty(t, logger, "日志信息不能为空")
}
func TestMultiSingle(t *testing.T) {
logger := Ne... |
package music_test
import (
"git.ronaksoftware.com/blip/server/internal/tools"
testEnv "git.ronaksoftware.com/blip/server/pkg"
"git.ronaksoftware.com/blip/server/pkg/music"
. "github.com/smartystreets/goconvey/convey"
"testing"
"time"
)
/*
Creation Time: 2020 - Feb - 01
Created by: (ehsan)
Maintainers... |
package stack
type ErrorStack struct {
Err error
Cause string
}
func (es *ErrorStack) Error() string {
return es.Err.Error() + es.Cause
}
|
// /**
// * Created using VSCode
// * User : Sean
// * Simple web crawler example file to test how to query web pages and the displayed data
// */
// package main
// /*
// useful urls
// https://www.devdungeon.com/content/web-scraping-go
// https://tour.golang.org/concurrency/10
// http://edmundmartin.com/writing-a-w... |
// Copyright (C) 2021 Storj Labs, Inc.
// See LICENSE for copying information.
package rpctest
import (
"context"
"storj.io/common/rpc/rpcpool"
"storj.io/drpc"
)
// MessageHook is a function which may be called before and after an rpc call.
type MessageHook func(rpc string, message drpc.Message, err error)
// M... |
package metricstore_test
import (
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
"strconv"
"sync"
"time"
"github.com/cloudfoundry/metric-store-release/src/pkg/leanstreams"
"github.com/cloudfoundry/metric-store-release/src/pkg/metricstore"
"github.com/cloudfoundry/metric-store-re... |
package topic
import (
"net/http"
"gin_bbs/app/helpers"
userModel "gin_bbs/app/models/user"
"github.com/gin-gonic/gin"
)
// UploadImage 上传图片
func UploadImage(c *gin.Context, currentUser *userModel.User) {
data := gin.H{
"success": false,
"msg": "上传失败",
"file_path": "",
}
// 是否有上传文件
file, _ :=... |
package service
import (
"encoding/json"
"fmt"
"log"
"net/http"
"time"
"github.com/GeorgeMac/pontoon/build"
"github.com/GeorgeMac/pontoon/jobs"
"github.com/GeorgeMac/pontoon/monitor"
"github.com/gorilla/mux"
)
const BUILD_TIMEOUT time.Duration = 2 * time.Minute
type Service struct {
queue *jobs.JobQueue
... |
// 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 network
import (
"context"
"regexp"
"time"
"chromiumos/tast/common/hermesconst"
"chromiumos/tast/errors"
"chromiumos/tast/local/chrome"
"chromiumos/tast/loca... |
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <yazgazan@gmail.com> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can ... |
// SPDX-License-Identifier: MIT
package node
import (
"reflect"
"testing"
"github.com/issue9/assert/v3"
)
func TestParseValue(t *testing.T) {
a := assert.New(t, false)
v := ParseValue(reflect.ValueOf(intTag{}))
a.Equal(v.Name, "number").
Equal(v.Usage, "usage-number").
False(v.Omitempty)
v = ParseValue... |
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2018-04-06 08:50:46.765267888 +0900 JST m=+0.025988291
package docs
import (
"github.com/swaggo/swag"
)
var doc = `{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "Implement Data Caching Service using mic... |
package main
import "fmt"
func main() {
var i = 3
var j = 20
movij( &i , &j )
fmt.Println(i,j)
}
func movij( i , j ...*int) {
var mid int
mid = *i
*i = *j
*j = mid
} |
package lib
import "github.com/gabrielperezs/goreactor/reactorlog"
// Input is the interface for the Input plugins
type Input interface {
// Put(m Msg) error
//Delete(m Msg) error
Done(m Msg, status bool) // Input was processed and don't need to keep it as pending
Stop() // Stop accepting input
... |
package main
import "strings"
/*
/home/../../sub/./
*/
func simplifyPath(path string) string {
dirs := strings.Split(path, "/")
var canonicalPath []string
for _, d := range dirs {
if d == "" || d == "." {
continue
}
if d == ".." {
if len(canonicalPath) > 0 {
canonicalPath = canonicalPath[:len(can... |
package main
import "fmt"
func main() {
// Unsigned integer types:
var x uint8 = 0
var x uint16 = 0
var x uint32 = 0
var x uint64 = 0
// Signed integer types:
var x int8 = -1 // aka "byte"
var x int32 = -1 // aka "rune"
var x int64 = -1
// Floating point types:
var x flo... |
package main
/*
int fortytwo(void);
#include "main.h"
int mul(int, int);
*/
import "C"
import "unsafe"
func main() {
println("fortytwo:", C.fortytwo())
println("add:", C.add(C.int(3), 5))
var x C.myint = 3
println("myint:", x, C.myint(5))
println("myint size:", int(unsafe.Sizeof(x)))
var y C.longlong = -(1 << ... |
package odoo
import (
"fmt"
)
// BaseImportTestsModelsChar represents base_import.tests.models.char model.
type BaseImportTestsModelsChar struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
... |
// This file is part of CycloneDX GoMod
//
// 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 agr... |
package main
import (
"bufio"
"bytes"
"code.google.com/p/mahonia"
"io/ioutil"
"log"
"os"
"regexp"
"strconv"
"time"
)
const DAT_MAX_SIZE = 512 * 1024
var RegsLine = regexp.MustCompile(`(\d+)\.dat<>(?:.*\s\((\d+)\))`)
func main() {
path := "/2ch/dat"
dir, err := ioutil.ReadDir(path)
if err != nil {
log.... |
package main
import (
"database/sql"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"syscall"
"time"
_ "github.com/go-sql-driver/mysql"
"github.com/labstack/echo"
"github.com/patrickmn/go-cache"
articleDelivery "github.com/sesha04/test_kumparan/article/delivery"
articleRepo "github.com/sesha04/test_kumparan/ar... |
// Copyright 2020 The Moov Authors
// Use of this source code is governed by an Apache License
// license that can be found in the LICENSE file.
package fed
import (
"fmt"
"os"
"path/filepath"
"strings"
"testing"
"github.com/moov-io/base"
"github.com/stretchr/testify/require"
)
// loadTestWireFiles returns t... |
package postgres
import (
"context"
"database/sql"
"fmt"
"github.com/guregu/null"
"github.com/pganalyze/collector/state"
)
const functionsSQLDefaultKindFields = "CASE WHEN pp.proisagg THEN 'a' WHEN pp.proiswindow THEN 'w' ELSE 'f' END AS prokind"
const functionsSQLpg11KindFields = "pp.prokind"
const functionsS... |
package goutilmod
func Max(a int, b int) int {
if a > b {
return a
} else {
return b
}
}
func Min(a int, b int) int {
if a > b {
return b
} else {
return a
}
}
func MaxThree(a int, b int, c int) int {
if a > b {
if a > c {
return a
} else {
return c
}
} else {
if b > c {
return b
}... |
package gate
import (
"github.com/wudiliujie/common/gate"
"github.com/wudiliujie/common/log"
"github.com/wudiliujie/common/module"
"yxlserver/services/I/eventcode"
"yxlserver/services/conf"
"yxlserver/services/gconf"
"yxlserver/services/msg"
)
var Module = new(GateModule)
var netEvent = new(gate.NetEvent)
fu... |
package config
// Config represents Application global config.
type Config struct {
OpenAPIURL string
DateFormat string
ServiceKey string
Port string
}
|
package service
import (
"crypto/md5"
"encoding/hex"
"encoding/json"
"fmt"
"shared/common"
"shared/utility/errors"
"shared/utility/httputil"
"shared/utility/servertime"
"sort"
"strings"
)
var koMoeSessionVerifyUrl = "%s/api/server/session.verify"
// KoMoe 小萌sdk/*
type KoMoe struct {
host string ... |
package main
import "fmt"
import (
"errors"
"math"
)
/**
抛出异常的时候,返回值nil代表错误消息
*/
func sqrt(num float64) (float64, error) {
if num < 0 {
return 500, errors.New("入参不能为负数")
}
return math.Sqrt(num), nil
}
func main() {
f, e := sqrt(64)
fmt.Println(f, e)
sqrt, i := sqrt(-12)
fmt.Println(sqrt, i)
}
|
package ravendb
type OrderingType = string
const (
OrderingTypeString = "STRING"
OrderingTypeLong = "LONG"
OrderingTypeDouble = "DOUBLE"
OrderingTypeAlphaNumeric = "ALPHA_NUMERIC"
)
|
package core
const (
CreateUserEvent = "addUser"
RemoveUserEvent = "removeUser"
DumpUserEvent = "users"
HelloEvent = "hello"
)
|
package fun
import (
"github.com/BurntSushi/ty/fun"
)
func Map(xs, f interface{}) interface{} {
return fun.Map(f, xs)
}
|
//提供一个分等级的日志系统,建议直接使用全局的对象,而不是另外New一个
package logger
import (
"fmt"
"jscfg"
"log"
"os"
"path"
"runtime/debug"
"strconv"
"strings"
"sync"
//"sync/atomic"
"time"
"timer"
)
const (
CfgBaseDir = "../cfg/"
LogBaseDir = "../log/"
LogBaseDir2 = "../logbyday/"
)
//配置表
type stCfg struct {
LogNumPreFile uint... |
package chain
import (
"fmt"
"reflect"
)
/**
entity
*/
type Request struct {
tagId string
}
func (request *Request) SetTagId(tagId string) {
request.tagId = tagId
}
func (request *Request) GetTagId() string {
return request.tagId
}
type Response struct {
}
/**
interface
*/
type Handler interface {
DoHandler... |
package catalog
import (
"bytes"
"os"
"path/filepath"
"time"
"github.com/cidverse/cid/pkg/core/util"
"github.com/cidverse/cidverseutils/pkg/encoding"
"github.com/go-resty/resty/v2"
"github.com/rs/zerolog/log"
"gopkg.in/yaml.v3"
)
type Source struct {
URI string `yaml:"uri"`
AddedAt string `yaml:"a... |
package gube
import (
"fmt"
)
var _ = fmt.Errorf
type CachedGarden interface {
Reset()
Garden
}
type cached_garden struct {
Garden
projects ProjectCache
profiles ProfileCache
shoots ShootCache
}
var _ Garden = &cached_garden{}
func NewCachedGarden(g Garden) CachedGarden {
return (&cached_garden{}).new(g... |
package rate_type
import (
"sync"
"vcm/api"
)
type ZEC string
func (z *ZEC) UpdateRate(wg *sync.WaitGroup) {
defer wg.Done()
rate, err := api.FetchRate("zec_jpy")
if err != nil {
panic(err)
}
*z = ZEC(rate)
}
|
package acmetool
import "os"
// The state directory path to be used for a system-wide state storage
// directory. It may vary by system and platform. On most POSIX-like
// systems, it is "/var/lib/acme". Specific builds might customise
// it.
var DefaultStateDir string
// The hooks directory is the path at which ... |
package api
import (
"context"
"encoding/json"
"fmt"
"net/http"
"strings"
"github.com/porter-dev/porter/internal/models"
)
// GetProjectResponse is the response returned after querying for a
// given project
type GetProjectResponse models.ProjectExternal
// GetProject retrieves a project by id
func (c *Client... |
package pixivapi
import (
"os"
"testing"
)
func Test_generateHash(t *testing.T) {
type args struct {
data string
}
tests := []struct {
name string
args args
want string
}{
{
"given date",
args{"2019-12-19T16:02:07+00:00" + "28c1fdd170a5204386cb1313c7077b34f83e4aaf4aa829ce78c231e05b0bae2c"},
"... |
// Copyright 2020 The VectorSQL Authors.
//
// Code is licensed under Apache License, Version 2.0.
package config
import (
"os"
"github.com/naoina/toml"
)
type Server struct {
TCPPort int
HTTPPort int
DebugPort int
Path string
TmpPath ... |
// challenge :: https://www.hackerrank.com/challenges/a-very-big-sum
package sum
import "fmt"
func read(n int) ([]int, error) {
in := make([]int, n)
for i := range in {
_, err := fmt.Scan(&in[i])
if err != nil {
return in[:i], err
}
}
return in, nil
}
func main() {
var a, res int
fmt.Scanf("%v\n", &a... |
package command
import (
"github.com/goodmustache/pt/actor"
"github.com/goodmustache/pt/command/display"
)
//counterfeiter:generate . ProjectListActor
type ProjectListActor interface {
Projects() ([]actor.Project, error)
}
type ProjectList struct {
UserID uint64 `short:"u" long:"user-id" description:"User ID to... |
package prolog
import (
"bytes"
"encoding/binary"
"fmt"
"net/http"
)
// SocketWrite ..
func SocketWrite(serverAddr string, s string) (err error) {
client := &http.Client{}
url := serverAddr
buf := new(bytes.Buffer)
binary.Write(buf, binary.LittleEndian, []byte(s))
request, err := http.NewRequest("POST", url... |
/*
Copyright 2014 Huawei Technologies Co., Ltd. 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 la... |
package sentryhook
import (
"runtime"
"strings"
"github.com/getsentry/sentry-go"
)
// NewStacktrace creates a stacktrace using `runtime.Callers`.
func NewStacktraceForHook() *sentry.Stacktrace {
pcs := make([]uintptr, 100)
n := runtime.Callers(1, pcs)
if n == 0 {
return nil
}
frames := extractFrames(pcs[... |
package fiberx
import (
"regexp"
"github.com/go-playground/locales/en"
ut "github.com/go-playground/universal-translator"
"github.com/go-playground/validator/v10"
ent "github.com/go-playground/validator/v10/translations/en"
"github.com/gofiber/fiber/v2/utils"
)
// V is an instance of *validator.Validate
// use... |
package main
import (
"bufio"
"fmt"
"log"
"os"
"sort"
"strings"
)
type state struct {
votes int
value map[int]float64 // issue.id -> fraction of votes
}
type issue struct {
id int
name string
cost int
frac float64 // total fractional votes
}
type descend []issue
func (s descend) Len() int { return le... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.