text stringlengths 11 4.05M |
|---|
package output
import (
"context"
"fmt"
"github.com/benthosdev/benthos/v4/public/service"
)
func init() {
err := service.RegisterOutput(
"blue_stdout", service.NewConfigSpec(),
func(conf *service.ParsedConfig, mgr *service.Resources) (out service.Output, maxInFlight int, err error) {
return &blueOutput{},... |
package ice
import (
"bytes"
"fmt"
)
/*
SessionCheckState describes the state of ICE check.
*/
type SessionCheckState int
const (
/**
* A check for this pair hasn't been performed, and it can't
* yet be performed until some other check succeeds, allowing this
* pair to unfreeze and move into the Waiting sta... |
package main
import (
"fmt"
"io"
"net/http"
"github.com/jbenet/go-ipfs/core"
"github.com/jbenet/go-ipfs/core/coreunix"
"github.com/jbenet/go-ipfs/importer"
"github.com/jbenet/go-ipfs/importer/chunk"
"github.com/jbenet/go-ipfs/repo/fsrepo"
uio "github.com/jbenet/go-ipfs/unixfs/io"
u "github.com/jbenet/go-ipf... |
// Copyright 2020 MongoDB 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... |
package internal
import (
"context"
"github.com/matrix-org/dendrite/roomserver/api"
)
func (r *RoomserverInternalAPI) PerformPublish(
ctx context.Context,
req *api.PerformPublishRequest,
res *api.PerformPublishResponse,
) {
err := r.DB.PublishRoom(ctx, req.RoomID, req.Visibility == "public")
if err != nil {
... |
/*
For each row and then column of a matrix, we can add an extra entry with the sum of the last two entries in that row or column. For example with the following input matrix:
[ 1 1 1 ]
[ 2 3 4 ]
The resulting matrix would be:
[ 1 1 1 2 ]
[ 2 3 4 7 ]
[ 3 4 5 9 ]
Given an input of an integer N and an [X,Y] matrix of ... |
package main
import (
"io/ioutil"
"github.com/op/go-logging"
"os"
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022/pacs"
)
var LOGGER = logging.MustGetLogger("main")
func main() {
pacsMessage, err := ioutil.ReadFile("./example-message.xml")
if err != nil {
LOGGER.Fatalf("Unable to read... |
// miscellaneous utility functions used for the landing page of the application
package newRequest
import (
"glsamaker/pkg/models"
"glsamaker/pkg/models/users"
"html/template"
"net/http"
)
// renderIndexTemplate renders all templates used for the landing page
func renderNewTemplate(w http.ResponseWriter, user *u... |
package emasmav1
import (
"context"
"fmt"
"math"
"strconv"
"strings"
"sync"
"github.com/markcheno/go-talib"
"github.com/mhereman/cryptotrader/algorithms"
"github.com/mhereman/cryptotrader/interfaces"
"github.com/mhereman/cryptotrader/logger"
"github.com/mhereman/cryptotrader/types"
)
const (
name string... |
//File : ${NAME}.go
//Author: 燕人Lee&骚气又迷人的反派
//Date : ${DATE}
package main
import (
"fmt"
)
func main() {
fmt.Println("start")
}
package ${GO_PACKAGE_NAME}
|
package influxql
import (
"encoding/binary"
"errors"
"fmt"
"hash/fnv"
"sort"
"strings"
"time"
)
// DB represents an interface to the underlying storage.
type DB interface {
// Returns a list of series data ids matching a name and tags.
MatchSeries(name string, tags map[string]string) []uint32
// Returns a ... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/8/22 7:47 上午
# @File : lt_21_合并2个有序链表.go
# @Description :
# @Attention :
*/
package offer
// 关键: 直接暴力遍历即可
func mergeTwoLists(l1 *ListNode, l2 *ListNode) *ListNode {
dummy := &ListNode{}
tmp := dummy
for nil != l1 && nil != l2 {
if l1.Val < l2.Val {
tm... |
package Problem0355
import "sort"
import "time"
type tweet struct {
id int
time int64
}
// tweets 用于排序
type tweets []tweet
func (t tweets) Len() int {
return len(t)
}
func (t tweets) Less(i, j int) bool {
return t[i].time > t[j].time
}
func (t tweets) Swap(i, j int) {
t[i], t[j] = t[j], t[i]
}
// Twitter is... |
package mhfpacket
import (
"errors"
"github.com/Andoryuuta/Erupe/network"
"github.com/Andoryuuta/Erupe/network/clientctx"
"github.com/Andoryuuta/byteframe"
)
// MsgSysLogin represents the MSG_SYS_LOGIN
type MsgSysLogin struct {
AckHandle uint32
CharID0 uint32
LoginTokenNumber ... |
package main
func main() {
}
func averageOfLevels(root *TreeNode) (averages []float64) {
nextLevel := []*TreeNode{root}
for len(nextLevel) > 0 {
sum := 0
curLevel := nextLevel
nextLevel = nil
for _, node := range curLevel {
sum += node.Val
if node.Left != nil {
nextLevel = append(nextLevel, node.... |
package main
import (
"bufio"
"fmt"
"io/ioutil"
"log"
"os"
"strings"
"github.com/nlopes/slack"
"github.com/tarm/serial"
)
const (
slackUserID = "YOURUSERID"
slackToken = "YOURLEGACYTOKEN"
)
func initializePort(path string) *serial.Port {
c := new(serial.Config)
c.Name = path
c.Baud = 115200
c.Size = ... |
package log
import "sync"
// byteArrayPool represents a reusable byte pool. It is a centralized global instance for this package and can be
// accessed by calling log.BytePool(). It is intended to be used by Handlers.
type byteArrayPool struct {
pool *sync.Pool
}
func (p *byteArrayPool) Get() *Buffer {
return p.po... |
package goreq
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"reflect"
)
// RespHandler you can implement some special cases
// TIPS: Usually JsonResp, RawResp and HybridResp handle most situations
type RespHandler interface {
HandleResponse(resp *http.Response, respWrapper Wrapper) error
}
// RawResp u... |
package server
import (
"net/http"
"github.com/cinus-ue/securekit/internal/webapps/fileserver/util"
)
func (h *handler) hsts(w http.ResponseWriter, r *http.Request) (needRedirect bool) {
_, port := util.ExtractHostnamePort(r.Host)
if len(port) > 0 {
return
}
header := w.Header()
header.Set("Strict-Transpo... |
// Copyright 2015 PingCAP, 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 i... |
package users
import (
mock_user_repo "2019_2_IBAT/pkg/app/users/service/mock_user_repo"
"fmt"
"testing"
"time"
. "2019_2_IBAT/pkg/pkg/models"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
)
func TestUserService_CreateFavorite(t *test... |
package util
import (
"crypto/md5"
"crypto/sha256"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/sha3"
"github.com/ethereum/go-ethereum/rlp"
"github.com/sanguohot/medichain/zap"
)
func RlpHash(x interface{}) (h common.Hash) {
h... |
package main
/*
* @lc app=leetcode id=46 lang=golang
*
* [46] Permutations
*/
// 方法一:选择法 + 挑选记录数组
func permute(nums []int) [][]int {
res := make([][]int, 0, len(nums))
helper_46_2(&res, nums, make([]int, len(nums)), 0, make([]bool, len(nums)))
return res
}
func helper_46_2(res *[][]int, nums, p... |
package light
import (
"github.com/calbim/ray-tracer/src/color"
"github.com/calbim/ray-tracer/src/tuple"
)
//Light represents a light of given intensity at a position
type Light struct {
Intensity color.Color
Position tuple.Tuple
}
//PointLight returns a light originating at point p and intensity i
func PointL... |
package handler
import (
"net/http"
"github.com/teejays/clog"
"github.com/teejays/n-factor-vault/backend/library/go-api"
"github.com/teejays/n-factor-vault/backend/library/id"
"github.com/teejays/n-factor-vault/backend/src/totp"
)
type CreateAccountRequest struct {
Name string
PrivateKey string
}
// ... |
package goSolution
import (
"reflect"
"runtime/debug"
"strconv"
"strings"
"testing"
"unicode/utf8"
)
func AssertEqual(t *testing.T, b interface{}, a interface{}) {
if reflect.DeepEqual(a, b) {
return
}
debug.PrintStack()
t.Errorf("Received %v (type %v), expected %v (type %v)", a, reflect.TypeOf(a), b, ref... |
package main
import (
"bytes"
"fmt"
"regexp"
"strings"
corev2 "github.com/sensu/sensu-go/api/core/v2"
"github.com/sensu/sensu-plugins-go-library/sensu"
"github.com/bluele/slack"
)
type HandlerConfig struct {
sensu.PluginConfig
SlackWebhookUrl string
SlackChannel string
SlackUsername ... |
package models
import "time"
type SysLog struct {
ID int `gorm:"primary_key" json:"id"` //日志id
UserId int `json:"user_id"` //操作用户id
Description string `json:"description"` //描述
LogType int `json:"log_type"` //日志类型
Method ... |
package main
import (
"bufio"
"flag"
"fmt"
"io"
"os"
"sync"
"github.com/fatih/color"
"golang.org/x/net/websocket"
)
// Current version number
const Version = "0.0.0"
var (
origin string
url string
protocol string
displayHelp bool
displayVersion bool
red = color.N... |
// Copyright 2022 Google LLC. 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 applica... |
package handlers
import (
"encoding/json"
"io"
"net/http"
"github.com/root-gg/plik/server/common"
"github.com/root-gg/plik/server/context"
)
// LoginParams to be POSTed by clients to authenticate
type LoginParams struct {
Login string `json:"login"`
Password string `json:"password"`
}
// LocalLogin handle... |
// Copyright (c) 2016, Gerasimos Maropoulos
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of c... |
package main
import (
"fmt"
"io"
"strings"
)
/*
io.Reader interface is used by lots of go libraries.
it has a .Read() method
strings.NewReader() is one library that's satisfies io.Reader interface
byte-by-byte chunks are read, and io.EOF error marks when stream ends.
*/
func main() {
r := strings.NewRead... |
package base
import (
"errors"
"fmt"
"gengine/context"
"gengine/internal/core"
"reflect"
"runtime"
"strings"
)
// := or =
type Assignment struct {
SourceCode
Variable string
MapVar *MapVar
AssignOperator string
MathExpression *MathExpression
Expression *Expression
}
func (a *Assignment... |
package slow_tasks
import (
"encoding/base32"
ldap_client "github.com/lucabodd/go-ldap-client"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"log"
"context"
. "github.com/lucabodd/maicsd/pkg/utils"
"strings"
)
typ... |
package B
import "fmt"
func Call() {
fmt.Println("B!")
} |
package main
func (a *App) initializeRoutes() {
a.Router.HandleFunc("/companies", a.getCompanies).Methods("GET")
a.Router.HandleFunc("/company/{id:[0-9]+}", a.getCompany).Methods("GET")
}
|
package util
import (
"context"
"time"
)
// Sleeper is a device that facilitates Context-cancellable sleeping.
//
// Sleeper is not safe for concurrent usage.
type Sleeper struct {
t *time.Timer
}
// Sleep sleeps until either the specified period, d, has expired, or the
// supplied Context has been cancelled.
//
... |
package validation
import (
"fmt"
"reflect"
validator "gopkg.in/validator.v2"
)
func NewValidator(name string, registry interface{}) {
validator.SetValidationFunc(
name,
func(v interface{}, param string) error {
st := reflect.ValueOf(v)
if st.Kind() == reflect.Ptr {
if st.Pointer() == 0 {
retu... |
package main
import (
"encoding/json"
"fmt"
"os"
"github.com/SoftwareAG/adabas-go-api/adabas"
"github.com/SoftwareAG/adabas-go-api/adatypes"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
// Employees example exmployee native inmap usage
type Employees struct {
Index uint64 `adabas:":isn"`
ID ... |
package genstruct
import (
"io/ioutil"
"strings"
)
const (
golangByteArray = "[]byte"
gureguNullInt = "null.Int"
sqlNullInt = "sql.NullInt64"
golangInt = "int"
golangInt64 = "int64"
gureguNullFloat = "null.Float"
sqlNullFloat = "sql.NullFloat64"
golangFloat = "float"
golangF... |
package _783_Minimum_Distance_Between_BST_Nodes
import "math"
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
func minDiffInBST(root *TreeNode) int {
return minDiffInBSTInOrderNR(root)
}
func minDiffInBSTInOrderNR(root *TreeNode) int {
var (
stack []*TreeNode
node = root
pre *TreeNo... |
package handlers
import (
"forum/internal/handlers/dashboard"
"github.com/gin-gonic/gin"
)
func dashboardRouter(r *gin.RouterGroup) {
r.POST("forum", dashboard.CreateForum)
r.GET("forum", dashboard.AllForum)
r.GET("forum/:forum", dashboard.ShowForum)
r.DELETE("forum/:forum", dashboard.DeleteForum)
r.PUT("foru... |
/*
You are driving a little too fast, and a police officer stops you. Write code to compute the result, encoded as an int value: 0=no ticket, 1=small ticket, 2=big ticket. If speed is 60 or less, the result is 0. If speed is between 61 and 80 inclusive, the result is 1. If speed is 81 or more, the result is 2. Unless i... |
package pget
import (
"bytes"
"context"
"crypto/md5"
"encoding/hex"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestMain(m *testing.M) {
stdout = ioutil.Discard
os.Exit(m.Run())
}
func TestPget(t *testing.T) ... |
package main
import(
"fmt"
"log"
"net/http"
"encoding/json"
)
type Passage struct {
Company string `json:"Company"`
Money string `json:"Money"`
}
type Passages []Passage
func enableCors(w *http.ResponseWriter) {
(*w).Header().Set("Access-Control-Allow-Origin", "*")
}
func allPassages(w http.ResponseWriter,... |
package main
import (
"os"
"path"
"path/filepath"
"strings"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/mattn/go-shellwords"
"github.com/ayufan/docker-composer/cmds"
"github.com/ayufan/docker-composer/compose"
)
func init() {
workTree := os.Getenv("GIT_WORK_TREE")
if workTree == "" {... |
package 链表
func hasCycle(head *ListNode) bool {
slow,fast := head,head
for fast!=nil && fast.Next!=nil{
slow = slow.Next
fast=fast.Next.Next
if slow==fast{
return true
}
}
return false
}
/*
题目链接: https://leetcode-cn.com/problems/linked-list-cycle/comments/
*/
|
package TmxTileset
import (
"testing"
)
var testTilesets= [...]string{"../../../tilesets/jumper.tsx"}
func TestTilesetParsingp(t *testing.T) {
for _, filename := range testTilesets {
ReadTileSetFile(filename)
}
} |
package moviedetail
import (
"context"
"github.com/ariefrpm/movies2/gen/go/proto/v1"
"github.com/ariefrpm/movies2/pkg/library/router"
"google.golang.org/grpc"
)
type request struct {
ID string
}
type response struct {
*Movie
}
func endpoint(s Service) router.Endpoint {
return func(ctx context.Context, req in... |
package logger
import (
"log"
"os"
)
var (
outfile, _ = os.OpenFile("./logger/info.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0755)
LogFile = log.New(outfile, "", 0)
)
func ForError(err error) {
if err != nil {
LogFile.Println(err)
// LogFile.Fatal(err)
}
}
func LogCommandResult(str string){
if str != "... |
package firewall
import "fmt"
type Mock struct {
}
func (f *Mock) AddIP(ip string) error {
//fmt.Printf("sudo /sbin/ipset add blacklist %s\n", ip)
return nil
}
func (f *Mock) RemoveIP(ip string) error {
fmt.Printf("sudo /sbin/ipset del blacklist %s\n", ip)
return nil
}
|
package main
import (
"KServer/manage"
"KServer/manage/config"
"KServer/server/utils"
"KServer/server/utils/msg"
"KServer/server/websocket/response"
"KServer/server/websocket/services"
"fmt"
"os"
"os/signal"
"syscall"
)
func main() {
mConf := config.NewManageConfig()
//mConf.Socket.Client = true
//mConf.... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/7/7 9:47 上午
# @File : jz_24_二叉树中某个值的路径.go
# @Description :
# @Attention :
*/
package offer
func FindPath(root *TreeNode, expectNumber int) [][]int {
r := make([][]int, 0)
dfsFindPath(root, expectNumber, &r, make([]int, 0))
return r
}
func dfsFindPath(root... |
package command
import (
"errors"
"fmt"
"github.com/opsgenie/opsgenie-go-sdk-v2/logs"
gcli "github.com/urfave/cli"
"io"
"net/http"
"os"
"strings"
"time"
)
func NewCustomerLogClient(c *gcli.Context) (*logs.Client, error) {
logsCli, cliErr := logs.NewClient(getConfigurations(c))
if cliErr != nil {
message ... |
package main
import (
"fmt"
"strings"
)
func wordFrequency(text string) {
words := strings.Fields(text)
freq := make(map[string]int)
for i, word := range words {
words[i] = strings.Trim(word, ".!?;',")
words[i] = strings.ToLower(words[i])
freq[words[i]]++
}
for word, freq := range freq {
if freq > 1 {... |
package autoscaler
import "fmt"
type InstanceVariety struct {
InstanceType string
Subnet Subnet
}
func (v InstanceVariety) Capacity() (float64, error) {
return CapacityFromInstanceType(v.InstanceType)
}
type SortInstanceVarietiesByCapacity []InstanceVariety
func (s SortInstanceVarietiesByCapacity) Len() i... |
package main
import (
"os"
"github.com/nyks06/go-logger"
)
func main() {
//First of all, you need to Init the logger.
//You'll have to do it only one time in your program and you'll have to save the returned pointer.
//These functions show you how to add a logger type.
//You can add as much logger as you wan... |
/*
Copyright © 2021 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writi... |
package main
import (
"testing"
)
func BenchmarkMasterRegister1_5(b *testing.B) {
benchmarkRegister(1, 5, b)
}
func BenchmarkMasterRegister10_5(b *testing.B) {
benchmarkRegister(10, 5, b)
}
func BenchmarkMasterRegister100_5(b *testing.B) {
benchmarkRegister(100, 5, b)
}
func BenchmarkMasterRegister1000_5(b *te... |
package logs
import (
"errors"
"fmt"
"os"
"strings"
"sync"
"testing"
"time"
"github.com/10gen/realm-cli/internal/cli"
"github.com/10gen/realm-cli/internal/cloud/realm"
"github.com/10gen/realm-cli/internal/utils/test/assert"
"github.com/10gen/realm-cli/internal/utils/test/mock"
)
const (
testDateFormat = ... |
// This file was generated for SObject ContentVersionComment, API Version v43.0 at 2018-07-30 03:47:50.575198719 -0400 EDT m=+36.919190462
package sobjects
import (
"fmt"
"strings"
)
type ContentVersionComment struct {
BaseSObject
ContentDocumentId string `force:",omitempty"`
ContentVersionId string `force:",o... |
// Copyright 2023 PingCAP, 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 i... |
package gov
import (
"github.com/irisnet/irishub/app/v1/asset"
"github.com/irisnet/irishub/app/v1/auth"
distr "github.com/irisnet/irishub/app/v1/distribution"
"github.com/irisnet/irishub/app/v1/gov"
"github.com/irisnet/irishub/app/v1/mint"
"github.com/irisnet/irishub/app/v1/params"
"github.com/irisnet/irishub/a... |
// Copyright 2022 PingCAP, 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 i... |
package common
import (
"fmt"
"time"
)
// ProviderGoogle for authentication
const ProviderGoogle = "google"
// ProviderOVH for authentication
const ProviderOVH = "ovh"
// ProviderLocal for authentication
const ProviderLocal = "local"
// User is a Plik user
type User struct {
ID string `json:"id,omitempty"... |
// Copyright 2020 MongoDB 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... |
package main
import "fmt"
func main() {
fmt.Println(longestStrChain([]string{
"a", "b", "ba", "bca", "bda", "bdca",
}))
}
func longestStrChain(words []string) int {
wm := make(map[string]int)
for _, w := range words {
wm[w] = 0
}
max := func(a, b int) int {
if a > b {
return a
}
return b
}
va... |
package git
import (
"testing"
)
func TestResolveBaseBranch(t *testing.T) {
got, err := ResolveBaseBranch(nil)
if err != nil {
t.Errorf("error resolving branch: %s", err)
}
// will fail on a feature branch
want := "main"
if got != want {
t.Errorf("got %q, wanted %q", got, want)
}
}
|
package errors
// Kind is...
type Kind int
func (k Kind) String() string {
unexpected := "unexpected"
switch k {
case KindUnexpected:
return unexpected
case KindUnmarshal:
return "unmarshal"
case KindUser:
return "user"
default:
return unexpected
}
}
const (
// KindUnexpected is...
KindUnexpected K... |
package cpu
import (
_"fmt"
"time"
_"encoding/json"
"sysmonitor/profile"
"sysmonitor/common"
"github.com/shirou/gopsutil/cpu"
)
func CpuMonitor() string {
cpu_info, _ := cpu.Info()
cpu_percent, _ := cpu.Percent(time.Second, false)
cpustatus := new(profile.CpuStatus)
cpustatus.CPU = make([]profile.CpuInfo, ... |
package usecase
import (
"backend/models"
"backend/api"
"errors"
)
type ObjectCreator struct {
repo api.Repository
}
func NewObjectCreator(repo api.Repository) *ObjectCreator {
return &ObjectCreator {
repo: repo,
}
}
func (o *ObjectCreator) GetObjects(firstNumber, count int) ([]models.Obje... |
package main
import(
"github.com/griddb/go_client"
"fmt"
"os"
"strconv"
)
func main() {
factory := griddb_go.StoreFactoryGetInstance()
blob := []byte{65, 66, 67, 68, 69, 70, 71, 72, 73, 74}
// Get GridStore object
port, err := strconv.Atoi(os.Args[2])
if err != nil {
fmt.Println(err)
os.Exit(2)
}
gri... |
package main
import (
"runtime"
"time"
"github.com/akosgarai/opengl_playground/pkg/application"
wrapper "github.com/akosgarai/opengl_playground/pkg/glwrapper"
"github.com/akosgarai/opengl_playground/pkg/primitives/camera"
"github.com/akosgarai/opengl_playground/pkg/primitives/cuboid"
"github.com/akosgarai/open... |
package osbuild1
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewKernelCmdlineStage(t *testing.T) {
expectedStage := &Stage{
Name: "org.osbuild.kernel-cmdline",
Options: &KernelCmdlineStageOptions{},
}
actualStage := NewKernelCmdlineStage(&KernelCmdlineStageOptions{})
assert.Equal(... |
package conformance
import (
"fmt"
"os"
"strconv"
"github.com/bloodorangeio/reggie"
godigest "github.com/opencontainers/go-digest"
)
// TODO: import from opencontainers/distribution-spec
type (
TagList struct {
Name string `json:"name"`
Tags []string `json:"tags"`
}
)
const (
nonexistentManifest strin... |
package p2p
import (
"fmt"
)
// NetworkID represents the P2P network we are participating in (eg: test, nmain, etc.)
type NetworkID uint32
// NetworkID are specific uint32s to identify separate networks
//
// The default identifiers are MainNet (the main production network), TestNet (for network=TESTNET)... |
package factory
import (
"errors"
)
// Pokemon interface to implement on each pokemon object
type Pokemon interface {
Spawn()
}
// List of Pokemon we have
const (
CHARMANDER = iota + 1
PIKACHU
)
// CreatePokemon is the factory of pokemon
func CreatePokemon(poke int) (Pokemon, error) {
switch poke {
case CHARM... |
package main
import (
api_ctrl "./api/controllers"
"github.com/astaxie/beego"
clog "github.com/cihub/seelog"
)
// jzh: 这个是为了能单独跑起测试用的,通过ts.ini的[http]:[fake_api]项可以开启或者关闭
type RootController struct {
beego.Controller
}
func (self *RootController) Get() {
query := self.GetString("query")
if query == "alias" {
... |
package util
import (
"github.com/sanguohot/chardet"
"net/http"
"strings"
)
var defaultCharset = "utf-8"
var gbk = "gbk"
func DetectCharsetWithOnlyUtf8OrGbk(data []byte) string {
strs := chardet.Possible(data)
if strs[0] == defaultCharset {
return defaultCharset
}
foundGbk := false
for _, value := range str... |
package timer
import (
"container/list"
"context"
"time"
)
type eventType int
const (
add eventType = iota
remove
reset
)
type event struct {
typ eventType
wt *wheelTimer
}
type wheel struct {
ctx context.Context
stop context.CancelFunc
interval time.Duration
ticker *time.Ticker
pos in... |
package coding
import (
"fmt"
"github.com/sujit-baniya/smpp/coding/gsm7bit"
. "unicode"
. "golang.org/x/text/encoding"
"golang.org/x/text/encoding/charmap"
"golang.org/x/text/encoding/japanese"
"golang.org/x/text/encoding/korean"
"golang.org/x/text/encoding/unicode"
"golang.org/x/text/unicode/rangetable"
)
... |
package appStruct
import "github.com/therecipe/qt/widgets"
//структура хранит компоненты которые могут
//изменятся при работе программы
type GuiComponent struct{
Application *widgets.QApplication
WordList *widgets.QListWidget
MainWindow *widgets.QMainWindow
MainWidget *wi... |
package gojobs
import (
"sync"
)
// Func is a sceleton of executing functions
type Func func(data interface{}) (result interface{}, err error)
// Job specifies a job
type Job struct {
Data interface{}
Result interface{}
Error error
}
// New simply create a new instance of Structure Job
func New(data interfac... |
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright 2019 Dell, Inc. //
// ... |
package fmc
import (
"runtime"
"strings"
)
//Caller log run function
func Caller() {
pc := make([]uintptr, 40)
n := runtime.Callers(0, pc)
// Printfln("#rbtn= #gbt%d", n)
pc = pc[0:n] // pass only valid pcs to runtime.CallersFrames
frames := runtime.CallersFrames(pc)
i := 0
for {
frame, more := frames.Ne... |
package main
import "unicode/utf8"
func main() {
s := "雨.痕"
println(len(s), utf8.RuneCountInString(s))
}
|
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use ... |
package loadgen
import (
"fmt"
"github.com/prometheus/client_golang/prometheus"
"math/rand"
"strconv"
)
type (
incCollector struct {
descs []*prometheus.Desc
labelCount int
cycle int
}
)
func NewIncCollector(nmetrics, nlabels int) *incCollector {
descs := make([]*prometheus.Desc, nmetrics)
fo... |
// Copyright 2022 Google LLC. 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 applica... |
package mongomodel
import (
"time"
)
type LocationModel struct {
View *DailyLocationView
Typemap map[string]string
}
func NewLocationModel(date time.Time) *LocationModel {
locationmodel := LocationModel{
View: newDailyLocationView(date),
Typemap: make(map[string]string),
}
locationmodel.Typemap["北京市"... |
package main
import (
"fmt"
"github.com/kizzie/go-teampasswordmanager/teampasswordmanager"
)
func main() {
config := teampasswordmanager.ClientConfig{
BaseURL: "http://localhost/teampasswordmanager",
AuthToken: "a2F0OnBhc3N3b3Jk",
}
client, _ := teampasswordmanager.NewClient(&config)
fmt.Println(client... |
package grpc
import (
"fmt"
"log"
"net"
"github.com/charlesfan/go-grpc/pb"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)
const Protocol string = "tcp"
func Run(port string) {
fmt.Printf("[gRPC test] gRPC start service with %s on %s\n", Protocol, port)
lis, err := net.Listen(Protocol, port)
... |
package pci
import (
"fmt"
"runtime"
"apic"
"defs"
)
type pciide_disk_t struct {
rbase uintptr
allstat uintptr
bmaster uintptr
}
func attach_3400(vendorid, devid int, tag Pcitag_t) {
if Disk != nil {
panic("adding two disks")
}
gsi := pci_disk_interrupt_wiring(tag)
IRQ_DISK = gsi
INT_DISK = defs.IR... |
package config
import (
"github.com/jinzhu/gorm"
)
type Database struct {
Driver string
Host string
Port string
Database string
Username string
Password string
SslMode string
}
func (this *Database) Connect() *gorm.DB {
var dsn string
switch driver := this.Driver; { // missing expression means "... |
package biliLiveHelper
import (
"github.com/bitly/go-simplejson"
"math"
"sync"
)
const (
abortIndex = math.MaxInt8 / 2
)
type Context struct {
Cmd CmdType
Msg *simplejson.Json
keys map[string]interface{}
keysMutex *sync.RWMutex
handlers HandleChain
index int8
}
func NewContext(cmdTyp... |
// Copyright 2023 PingCAP, 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 i... |
package relation
import (
"fmt"
"log"
"strconv"
"github.com/ChowRobin/fantim/constant"
"github.com/ChowRobin/fantim/constant/status"
"github.com/ChowRobin/fantim/model/po"
"github.com/ChowRobin/fantim/model/vo"
"github.com/gin-gonic/gin"
)
func ListApply(c *gin.Context) interface{} {
resp := &vo.RelationAp... |
/*
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 may not use this fi... |
package domain
type DummyUser struct {
Username string `json:"username"`
Avatar string `json:"avatar"`
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.