text stringlengths 11 4.05M |
|---|
package main
import (
"net/http"
"os"
jwt "github.com/dgrijalva/jwt-go"
"errors"
"fmt"
)
func attemptAccess(r *http.Request, role string) error {
t, err := retrieveTokenFromHeader(r)
// If the token is empty...
if t == "" {
errors.New("No token provided")
}
if err != nil {
return err
... |
/*
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... |
package main
import "fmt"
type Canciones struct {
Nombres []string
}
type Banda struct {
Nombre string
Canciones // campo sin nombre de tipo Canciones, "campo anónimo"
}
func main() {
banda1 := Banda{
Nombre: "U2",
Canciones: Canciones{
Nombres: []string{"One", "Vertigo", "Elevation", "Stay"},
}, ... |
package main
import (
"flag"
"log"
nebula "github.com/vesoft-inc/nebula-go"
nt "github.com/vesoft-inc/nebula-test/nebulatest"
)
func main() {
file := flag.String("file", "", "Test file path")
username := flag.String("user", "user", "Nebula username")
password := flag.String("password", "password", "Nebula pas... |
package logrusutil
const (
// DisabledLevel may be passed into a *Config struct
// to disable logging and discard output.
DisabledLevel = "disabled"
)
var (
// DefaultLevel is the default log level used in NewConfig()
DefaultLevel = "warning"
// DefaultHookLevel is the default level where hooks will
// contri... |
package core
type Config struct {
Twitter *TwitterConfig `yaml:"twitter"`
Tumblr *TumblrConfig `yaml:"tumblr"`
Sources map[string]SourceConfig `yaml:"sources"`
}
type TwitterConfig struct {
ConsumerKey string `yaml:"consumer_key"`
ConsumerSecret string `yaml:"... |
package main
import (
"fmt"
)
// Create a new type "person" with underlying type as STRUCT
type person struct {
firstName string
lastName string
}
func main() {
// Create a value of type "person"
p1 := person{
firstName: "James",
lastName: "Bond",
}
p2 := person{
f... |
package element
const Sub = `
// Sub z = x - y mod q
{{- if eq .IfaceName .ElementName}}
func (z *{{.ElementName}}) Sub( x, y *{{.ElementName}}) *{{.ElementName}} {
{{else}}
func (z *{{.ElementName}}) Sub( x, y {{.IfaceName}}) {{.IfaceName}} {
{{end}}
var b uint64
var xar, yar = x.GetUint64(), y.GetUint64()... |
package osbuild1
// RPMOSTreeStageOptions configures the invocation of the `rpm-ostree`
// process for generating an ostree commit.
type RPMOSTreeStageOptions struct {
EtcGroupMembers []string `json:"etc_group_members,omitempty"`
}
func (RPMOSTreeStageOptions) isStageOptions() {}
// NewRPMOSTreeStage creates a new ... |
package body
import (
"github.com/realm/realm-server/items"
"github.com/realm/realm-server/items/armor"
)
// EBodyArmorType defines EBodyArmorType enums underlying type.
type EBodyArmorType string
// EBodyArmorType enums.
const (
LGHT EBodyArmorType = "Light"
MEDM EBodyArmorType = "Medium"
COMP EBodyArmorType =... |
package activemq
import (
"context"
"encoding/json"
"fmt"
"time"
"github.com/go-stomp/stomp"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
"github.com/batchcorp/plumber/validate"
"github.com/batchcorp/plumber-schemas/build/go/protos/args"
"github.com/batchcorp/plumber-schemas/build/go/protos/op... |
package ctcp
import (
"fmt"
"testing"
)
var ctcpTests = map[string]bool{
"\x01ACTION test message\x01": true,
"\x01THIS is a malformed CTCP message, but still good": true,
"\x01TEST\x01": true,
"\x01TEST \x01": true,
"\x01TEST ": ... |
package g2util
import (
"strconv"
)
// FloatPrecision 浮点型精度包装
func FloatPrecision(f *float64, p int) float64 {
s1 := strconv.FormatFloat(*f, 'f', p, 64)
*f, _ = strconv.ParseFloat(s1, 64)
return *f
}
|
package main
import (
"bufio"
"fmt"
"os"
"os/signal"
"strings"
"syscall"
. "github.com/SealNTibbers/GotalkInterpreter/evaluator"
)
// SetupCloseHandler creates a 'listener' on a new goroutine which will notify the
// program if it receives an interrupt from the OS. We then handle this by calling
// our clean ... |
package main
import (
"flag"
"fmt"
"log"
"net"
"net/http"
"os"
"os/signal"
"strings"
"syscall"
"time"
"github.com/gin-gonic/gin"
"github.com/polarismesh/polaris-go"
)
var (
namespace string
service string
token string
port int64
)
func initArgs() {
flag.StringVar(&namespace, "namespace",... |
package mira
import (
"net/http"
"time"
)
// Reddit is the main mira struct that practically
// does everything
type Reddit struct {
Token string `json:"access_token"`
Duration float64 `json:"expires_in"`
Creds Credentials
Chain chan *ChainVals
Stream Streaming
Values RedditVals
Client *http.... |
package main
import (
"log"
"net"
"github.com/Mrcampbell/pgo2/battle-service/config"
pgrpc "github.com/Mrcampbell/pgo2/battle-service/grpc"
"github.com/Mrcampbell/pgo2/battle-service/psql"
"github.com/Mrcampbell/pgo2/protorepo/pokemon"
"google.golang.org/grpc"
)
func main() {
// Set up a connection to the se... |
package compute
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
)
// IRule represents a load-balancer iRule.
type IRule struct {
ID string `json:"id"`
Name string `json:"name"`
VirtualListenerType string `json:"virtualListenerType"`
VirtualListenerProtocol strin... |
package problems
import (
"fmt"
"testing"
)
func Test_thirdMax(t *testing.T) {
type args struct {
nums []int
}
tests := []struct {
name string
args args
want int
}{
{
name: "example 1",
args: args{
nums: []int{3, 2, 1},
},
want: 1,
},
{
name: "example 2",
args: args{
nums... |
package main
import (
"net/http"
"github.com/gin-gonic/gin"
ginserver "github.com/go-oauth2/gin-server"
"gopkg.in/oauth2.v3/manage"
"gopkg.in/oauth2.v3/models"
"gopkg.in/oauth2.v3/server"
"gopkg.in/oauth2.v3/store"
)
func main() {
manager := manage.NewDefaultManager()
manager.MustTokenStorage(store.NewFileT... |
// Copyright 2018 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... |
// Copyright 2018 Diego Bernardes. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package flare
import (
"fmt"
"os"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/go-kit/kit/log/term"
)
const (
logLevelDeb... |
package main
import (
"fmt"
"os"
"bufio"
"strings"
)
const path = "input.txt"
func main() {
pipes := parseInput()
x := countGroups(pipes)
fmt.Println(x-1)
}
func countGroups(pipes [][]string) (c int) {
m := make(map[string]bool)
for i := range pipes {
m[pipes[i][0]] = false
}
done := false
for c = ... |
package client
import (
"context"
"mobingi/ocean/pkg/kubernetes/client/nodes"
"mobingi/ocean/pkg/log"
"time"
"mobingi/ocean/pkg/services/tencent"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
)
type Node struct {
Client *kubernetes.Clientset
Clust... |
package main
import "fmt"
func main(){
a := []int{1,2}
fmt.Printf("%T", a)
}
|
package storage_test
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"github.com/cloudfoundry/bosh-bootloader/fakes"
"github.com/cloudfoundry/bosh-bootloader/storage"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("StateBootstrap", func() {
Describe("GetState", func() {
var (
... |
// Copyright 2020 Frederik Zipp. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package canvas
import (
// Package embed is used to embed the HTML template and JavaScript files.
_ "embed"
"fmt"
"html/template"
"image/color"
"log"
"ne... |
package parser
import (
"fmt"
)
type Error struct {
Msg string
Line int // token pos line in source code
Pos int // token pos of source code
}
func (err Error) String() string {
return fmt.Sprintf("%s at Line:%v Pos:%v",
err.Msg, err.Line, err.Pos,
)
}
func (p *Parser) AddError(format string, args ...inte... |
package controllers
import (
"encoding/json"
"mall/models"
"github.com/astaxie/beego"
)
// Operations about Register
type RegisterController struct {
beego.Controller
}
// @Title Register
// @Description Register umsMember
// @Param body body models.UmsMember true "body for UmsMember content"
// @Success 200... |
package starfleet
import "github.com/zkynetio/crud-test/crud"
func Init() {
S := SuperCluster{}
crud.AddToRouteMap("/api/supercluster/:key/:value", "GET", S.GET)
crud.AddToRouteMap("/api/supercluster", "POST", S.CREATE)
crud.AddToRouteMap("/api/supercluster/:id", "DELETE", S.DELETE)
crud.AddToRouteMap("/api/supe... |
package system
import (
"os"
"github.com/sirupsen/logrus"
)
// NewLogger : logger
func NewLogger() *logrus.Logger {
log := logrus.New()
log.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
})
config := ViperInit()
if config.GetString("logger.level") == "debug" {
log.SetLevel(logrus.DebugLevel)... |
package dsl
import (
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
)
type ErrorListener struct {
Errors int
}
func (l *ErrorListener) ReportAmbiguity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, exact bool,
ambigAlts *antlr.BitSet, configs antlr.ATNConfigSet) {
}
func (l *ErrorListener... |
// miscellaneous utility functions used for the landing page of the application
package statistics
import (
"glsamaker/pkg/models"
"glsamaker/pkg/models/users"
"html/template"
"net/http"
)
// renderIndexTemplate renders all templates used for the landing page
func renderStatisticsTemplate(w http.ResponseWriter, ... |
// Copyright (c) 2018 Sylabs, Inc. 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 appli... |
package quark
import (
"bytes"
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"encoding/json"
"log"
"time"
)
func newSignature(key, data []byte) string {
h := hmac.New(sha256.New, key)
if _, e := h.Write(data); e != nil {
panic(e)
}
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
//easyjson:json... |
package rpcdb
import (
"net/http"
)
// Middleware represents the middleware
type middleware struct {
name string
next http.Handler
}
// NewMiddleware directly builds the middleware handler
func NewMiddleware(name string, next http.Handler) http.Handler {
return &middleware{name, next}
}
// Constructor returns a... |
package auth
import (
"fmt"
"testing"
)
func TestJWT(t *testing.T) {
token, err := GenerateToken(10175101201, "admin")
if err == nil {
fmt.Println(token)
}
claims, err := ParseToken(token)
if err == nil {
fmt.Println(claims)
}
}
|
package rakuten
type BooksService service
|
package util
//DbProperties contains all the data necessary to connect to a database
type DbProperties struct {
Host string
Port string
User string
Password string
Dbname string
}
|
package main
import (
"fmt"
)
func printArray() {
var arreglo [10]string //manera de declarar arreglo con 0 o vacio para cada elemento
array := [4]int{2, 5} // tiene 4 pero si no se especifican coloca 0 en el ultimo
for i := 0; i < len(arreglo); i++ {
for j := 0; j < len(array); j++ {
fmt.Print(array[j])
... |
package main
import (
"fmt"
"log"
"github.com/PI-Victor/passgen"
)
func main() {
newPass, err := passgen.GenPass(8, false, "")
if err != nil {
log.Panic(err)
}
fmt.Println(newPass)
}
|
package main
import (
"log"
"math/rand"
"net/http"
"net/http/httptest"
"strconv"
"sync"
"sync/atomic"
"time"
"github.com/go-pkgz/lcw"
"github.com/go-pkgz/repeater"
"github.com/go-pkgz/requester"
"github.com/go-pkgz/requester/middleware"
"github.com/go-pkgz/requester/middleware/cache"
"github.com/go-pkg... |
package stemsrepo
import (
"regexp"
"strings"
semiver "github.com/cppforlife/go-semi-semantic/version"
bhnotesrepo "github.com/bosh-io/web/stemcell/notesrepo"
)
var (
s3StemcellAgentRegexp = regexp.MustCompile(`ruby|go|agent`)
s3StemcellRegexp = regexp.MustCompile(`\A(([\w-]+/)?\w+/)?(?P<flavor>[\w-]+)-s... |
package offchainreporting
import (
"github.com/smartcontractkit/chainlink/core/logger"
ocrtypes "github.com/smartcontractkit/libocr/offchainreporting/types"
)
var _ ocrtypes.Logger = &ocrLogger{}
type ocrLogger struct {
internal *logger.Logger
trace bool
}
func NewLogger(internal *logger.Logger, trace bool) ... |
// Diretory-based cache.
package cache
import (
"encoding/base64"
"os"
"path"
"path/filepath"
"sort"
"sync"
"time"
"github.com/djherbis/atime"
"github.com/dustin/go-humanize"
"core"
)
type dirCache struct {
Dir string
added map[string]uint64
mutex sync.Mutex
}
func (cache *dirCache) Store(target *c... |
package main
import (
"fmt"
)
// 641. 设计循环双端队列
// 设计实现双端队列。
// 你的实现需要支持以下操作:
// MyCircularDeque(k):构造函数,双端队列的大小为k。
// insertFront():将一个元素添加到双端队列头部。 如果操作成功返回 true。
// insertLast():将一个元素添加到双端队列尾部。如果操作成功返回 true。
// deleteFront():从双端队列头部删除一个元素。 如果操作成功返回 true。
// deleteLast():从双端队列尾部删除一个元素。如果操作成功返回 tr... |
package time
import (
"sync"
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestSharedTime(t *testing.T) {
now := time.Now()
type args struct {
current time.Time
}
tests := []struct {
name string
s *SharedTime
args args
}{
{
name: "TestSet",
s: &SharedTime{
RWMutex: syn... |
package grpool
import (
"sync"
"time"
"github.com/tmpbook/go-app-core/pkg/common/timeout"
)
// Gorouting instance which can accept client jobs
type worker struct {
workerPool chan *worker
jobChannel chan Job
Jobresult chan Jobresult
jobtimeout time.Duration
stop chan bool
}
func (w *worker) start(poo... |
package opengraph
import (
"errors"
"github.com/golang/mock/gomock"
"github.com/nomkhonwaan/myblog/pkg/blog"
mock_blog "github.com/nomkhonwaan/myblog/pkg/blog/mock"
"github.com/nomkhonwaan/myblog/pkg/mongo"
"github.com/nomkhonwaan/myblog/pkg/storage"
mock_storage "github.com/nomkhonwaan/myblog/pkg/storage/mock"... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2020-08-19 10:22
# @File : lt_150_Evaluate_Reverse_Polish_Notation2.go
# @Description :
# @Attention :
*/
package stack
import "strconv"
func evalRPN2(tokens []string) int {
stack := make([]string, 0)
for _, v := range tokens {
switch v {
case "+", "-", ... |
package main
func rotateRight(head *ListNode, k int) *ListNode {
if head == nil || head.Next == nil || k== 0{
return head
}
dummyHead := &ListNode{}
dummyHead.Next = head
left := head
right := dummyHead
len := 0
for right.Next != nil {
len++
right = right.Next
}
k = k % len
// reset right
right = du... |
// +build go1.16
package main
import _ "embed"
//go:embed icon.png
var initIcon []byte
//go:embed icon16.png
var initIcon16 []byte
|
// 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 controllers
import (
"google.golang.org/appengine/delay"
"golang.org/x/net/context"
"github.com/aplulu/buyback/models/itemprice"
"google.golang.org/appengine/log"
"fareastdominions.com/evepaste/eve/market"
"google.golang.org/appengine/urlfetch"
"github.com/astaxie/beegae"
"strings"
"strconv... |
// 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 leetcode
import (
"reflect"
"testing"
)
func TestLetterCasePermutation(t *testing.T) {
if !reflect.DeepEqual(letterCasePermutation("a1b2"), []string{"a1b2", "a1B2", "A1b2", "A1B2"}) {
t.Fatal()
}
if !reflect.DeepEqual(letterCasePermutation("3z4"), []string{"3z4", "3Z4"}) {
t.Fatal()
}
if !reflect.D... |
// Package interfaces - list of interfaces to use
package interfaces
// MyTest - my test interface
type MyTest interface {
MyOutput() string
}
|
package main
import (
"fmt"
"net"
"os"
"strconv"
"time"
)
func checkErr(err error) {
if err != nil {
fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
}
}
func handlerClient(conn net.Conn) {
//conn.SetReadDeadline(time.Now().Add(10 * time.Second))
request := make([]byte, 128)
defer conn.Close()
f... |
package drivers
import (
"sync"
"github.com/complyue/ddgo/pkg/routes"
)
var (
// this var can be replaced to facilitate alternative service discovery mechanism
InitRoutesService = func(tid string) (*routes.ConsumerAPI, error) {
return routes.NewConsumerAPI(tid), nil
}
routesAPIs map[string]*routes.ConsumerA... |
package main
/*
1. Encapsulation - Go encapsulates things at the package level. Names that start with a lowercase letter are only visible within that package.
2. Composition, inheritance - No multiple inheritance.
3. Polymorphism
https://code.tutsplus.com/tutorials/lets-go-object-oriented-programming-in-golang--cms-... |
package main
import (
"log"
"net/http"
"github.com/gorilla/mux"
)
type Route struct {
Name string
Method string
Pattern string
HandlerFunc http.HandlerFunc
}
type Routes []Route
func NewRouter() *mux.Router {
r := mux.NewRouter().StrictSlash(true)
r.Path("/login").
Methods("GET").
Nam... |
package builtins
type ArrayClass struct {
valueStub
}
func NewArrayClass() Value {
a := &ArrayClass{}
a.class = NewClassValue().(Class)
a.initialize()
return a
}
func (klass *ArrayClass) New(args ...Value) Value {
a := &Array{}
a.initialize()
a.class = klass
a.AddMethod(NewMethod("shift", func(args ...Valu... |
package factories
import (
"github.com/barrydev/api-3h-shop/src/common/connect"
"github.com/barrydev/api-3h-shop/src/connections"
"github.com/barrydev/api-3h-shop/src/model"
)
func FindShipping(query *connect.QueryMySQL) ([]*model.Shipping, error) {
connection := connections.Mysql.GetConnection()
queryString :=... |
/*
* EVE Swagger Interface
*
* An OpenAPI for EVE Online
*
* OpenAPI spec version: 0.2.2
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obta... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/11/19 9:29 下午
# @File : lt_166_分数到小数.go
# @Description :
# @Attention :
*/
package offer
import (
"fmt"
"strconv"
)
// 参考: https://leetcode-cn.com/problems/fraction-to-recurring-decimal/solution/gong-shui-san-xie-mo-ni-shu-shi-ji-suan-kq8c4/
// 关键: 用草稿比比划... |
// Package engine - пакет поискового движка
package engine
import (
"encoding/json"
"errors"
"go.core/lesson7/pkg/cache"
"go.core/lesson7/pkg/crawler"
"go.core/lesson7/pkg/index"
"go.core/lesson7/pkg/storage"
)
type Service struct {
index index.Interface
storage storage.Interface
cache cache.Interface
}
... |
package directmessageinviteplugin
import (
"fmt"
"log"
"strings"
"github.com/matannoam/comicjerk"
)
func discordInviteID(id string) string {
id = strings.Replace(id, "://discordapp.com/invite/", "://discord.gg/", -1)
id = strings.Replace(id, "https://discord.gg/", "", -1)
id = strings.Replace(id, "http://disc... |
package router
import (
"net/http"
"../restAPI"
)
type Route struct {
Name string
Method string
Pattern string
HandlerFunc http.HandlerFunc
}
type Routes []Route
var routes = Routes{
Route{
"GetMetadata",
"GET",
"/rest_api/",
restAPI.GetMetadata,
},
Route{
"SignUp",
"POST",
"... |
package templete
import (
"bytes"
"github.com/agui2200/GoMybatisV2/utils"
"github.com/agui2200/GoMybatisV2/xml"
"github.com/beevik/etree"
"reflect"
"strconv"
"strings"
)
var equalOperator = []string{"/", "+", "-", "*", "**", "|", "^", "&", "%", "<", ">", ">=", "<=", " in ", " not in ", " or ", "||", " and ", "... |
package equinix
import (
"context"
"fmt"
"regexp"
"sort"
"time"
"github.com/equinix/ne-go"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
var networkDeviceSoftwareSchemaNames ... |
package protol
import (
"encoding/json"
)
type Protocol struct {
Action string `json:"action"`
Body map[string]interface{} `json:"body"`
Headers map[string]string `json:"headers"`
}
// Convert a protocol to json string.
func (protocol *Protocol) ToBytes() []byte {
bytes, _ := json.Marshal(protocol)
return by... |
package slack
import (
"log"
"net/http/httptest"
"sync"
)
const (
validToken = "testing-token"
)
var (
serverAddr string
once sync.Once
)
func startServer() {
server := httptest.NewServer(nil)
serverAddr = server.Listener.Addr().String()
log.Print("Test WebSocket server listening on ", serverAddr)
}
|
package updater
import (
"fmt"
"github.com/BukkitAPI-Translation-Group/docsbox/conf"
"github.com/BukkitAPI-Translation-Group/docsbox/middleware"
"github.com/BukkitAPI-Translation-Group/docsbox/util"
"github.com/BukkitAPI-Translation-Group/docsbox/versions"
"github.com/kballard/go-shellquote"
"github.com/labstac... |
package gracefully
import (
"log"
"testing"
"time"
)
func TestGracefullExample(t *testing.T) {
var stopCh = SetupSignalHandler()
go func() {
for {
log.Println("alive...")
time.Sleep(1 * time.Second)
}
}()
<-stopCh
log.Println("gracefully shutdown")
}
|
/*
Copyright 2022 The KubeVela 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, softw... |
package russian
func daysByCase(nnc numeralNumberCase) string {
switch nnc {
case singularNominative:
return "день"
case singularGenitive:
return "дня"
case pluralGenitive:
return "дней"
default:
return ""
}
}
// Days returns russian for 'day' corresponding to i.
func Days(i int64) string {
return days... |
package main
import (
"log"
"github.com/thedevelopnik/netplan/pkg/models"
"github.com/thedevelopnik/netplan/pkg/config"
"github.com/gin-gonic/gin"
database "github.com/thedevelopnik/netplan/pkg/db"
"github.com/thedevelopnik/netplan/pkg/service"
"github.com/thedevelopnik/netplan/pkg/transport"
)
// need to:
... |
/*
The flag of Bangladesh is very simple. It looks like below:
enter image description here
The flag will be in bottle green (#006a4e) and rectangular in size in the proportion of length to width of 10:6, with a red circle in near middle.
The red circle (#f42a41) will have a radius of one-fifth of the length of the ... |
package tgo
import (
"math/rand"
"sync"
"time"
)
var (
mysqlClusterConfig *ConfigMysqlCluster
mysqlClusterConfigMux sync.Mutex
)
type ConfigMysqlCluster struct {
MysqlCluster []*ConfigMysql
}
func NewConfigMysqlCluster() *ConfigMysqlCluster {
return &ConfigMysqlCluster{}
}
func ConfigMysqlClusterGetAll()... |
// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package main
import (
"context"
"crypto/sha256"
"flag"
"fmt"
"net/http"
"os"
"time"
"github.com/vivint/infectious"
"storj.io/storj/pkg/eestream"
"storj.io/storj/pkg/ranger"
)
var (
addr = flag.String("addr", "localh... |
package k8sml
import (
"gopkg.in/yaml.v3"
"reflect"
"strings"
"errors"
terraform "KubeArch/kubearch/proletarian/terraform"
)
type Subnet struct {
ID string
AvailabilityZone string
Cidr string
Public bool
RuntimeVariables map[string]string
Kubernetes *Kubernetes
RouteTable []*RouteTable
VirtualFirewall [... |
package fibrechannel
import (
"github.com/Huawei/eSDK_K8S_Plugin/src/utils"
"github.com/Huawei/eSDK_K8S_Plugin/src/utils/log"
)
func scanHost() {
output, err := utils.ExecShellCmd("for host in $(ls /sys/class/fc_host/); " +
"do echo \"- - -\" > /sys/class/scsi_host/${host}/scan; done")
if err != nil {
log.War... |
// Copyright 2014 Gyepi Sam. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package bridge simplifies the creation of a password encoder by abstracting out the generic parts.
// Concrete implementations that use this package can be great... |
package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/dop251/goja"
"github.com/dop251/goja_nodejs/console"
"github.com/dop251/goja_nodejs/require"
)
func main() {
if len(os.Args) < 2 {
fmt.Printf("Usage: %s <jsfile>\n", os.Args[0])
os.Exit(1)
}
fmt.Println("running", os.Args[1])
b, err := ioutil.Rea... |
// Copyright 2014 The Sporting Exchange Limited. All rights reserved.
// Use of this source code is governed by a free license that can be
// found in the LICENSE file.
// +build windows
package network
const DefaultPath = "network.xml"
|
/*
Copyright 2019 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.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, ... |
package config
import (
"time"
)
type Security struct {
SignAlg string `default:"HS256"`
TokenLife int64 `default:"60"` // 60 minute
RefreshIn int64 `default:"5"` // last 5 minute
WxOauthPath string `default:"/oauth/wechat"`
ExpiresMinute time.Duration `default:"61... |
//遍历
package main
import "fmt"
func main() {
slice := []map[string]string{}
mapTest := map[string]string{
"name": "test",
"age": "1",
}
slice = append(slice, mapTest)
mapTest = map[string]string{
"name": "test1",
"age": "22",
}
slice = append(slice, mapTest)
fmt.Println(slice)
var mySlice []map[str... |
package skpsilk
// silk/src/SKP_Silk_regularize_correlations_FIX.c
func regularize_correlations_FIX(XX []int32, xx []int32, noise int32, D int) {
for i := 0; i < D; i++ {
XX[D*i+i] += noise
}
xx[0] += noise
}
|
package mhfpacket
import (
"errors"
"github.com/Andoryuuta/Erupe/network"
"github.com/Andoryuuta/Erupe/network/clientctx"
"github.com/Andoryuuta/byteframe"
)
// MsgMhfSetCaAchievement represents the MSG_MHF_SET_CA_ACHIEVEMENT
type MsgMhfSetCaAchievement struct{}
// Opcode returns the ID associated with this pac... |
package appenginetesting
import (
"testing"
"appengine/datastore"
"appengine/memcache"
)
type Entity struct {
Foo, Bar string
}
func TestContext(t *testing.T) {
c, err := NewContext(nil)
if err != nil {
t.Fatalf("NewContext: %v", err)
}
defer c.Close()
_, err = memcache.Get(c, "foo")
if err != memcach... |
package utils
func Get(url string) {
}
|
package main
import (
"fmt"
"github.com/tealeg/xlsx"
)
func main() {
write()
}
//read
func read() {
exceName := "test_write.xlsx"
xlFile, err := xlsx.OpenFile(exceName)
if err != nil {
panic(err)
}
for _, sheet := range xlFile.Sheets {
fmt.Println("Sheet Name ", sheet.Name)
for _, row := range she... |
package handler
import (
"context"
"path/filepath"
"testing"
"github.com/google/uuid"
proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/core/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
// SubmitRemarkTestSuite 是 SubmitRemark rpc 的单元测试的 Test Suite
type SubmitRem... |
package backend
import (
"math"
"time"
"github.com/shirou/gopsutil/cpu"
)
// CPUUsage = Struct of CPU Usages
type CPUUsage struct {
Average int `json:"avg"`
Cores int `json:"cores"`
Info []cpu.InfoStat `json:"info"`
}
// GetCPUUsage = Get CPU Usage
func (s *Stats) GetCPUUsage() *CPU... |
package model
type StatisticsPerMuxing struct {
// ID of the stream
StreamId string `json:"streamId,omitempty"`
// ID of the muxing
MuxingId string `json:"muxingId,omitempty"`
// Multiplier for the encoded minutes. Depends on muxing type.
Multiplicator *float64 `json:"multiplicator,omitempty"`
// Encoded bytes.... |
// Copyright (C) 2015 Nicolas Lamirault <nicolas.lamirault@gmail.com>
// 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 ... |
// Copyright 2019 Yunion
//
// 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 dropbox
import (
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files"
"io"
)
//go:generate counterfeiter . client
type client interface {
Upload(arg *files.CommitInfo, content io.Reader) (res *files.FileMetadata, err error)
Download(arg *files.DownloadArg) (res *files.FileMetadata, content io.Read... |
package util
import (
"testing"
"time"
"github.com/google/go-cmp/cmp"
)
func TestFormatDuration(t *testing.T) {
cases := []struct {
d time.Duration
expected string
}{
{
5*time.Hour + 4*time.Minute + 205*time.Millisecond,
"5:04:00.2",
},
{
4*time.Minute + 15*time.Second + 205*time.Milli... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.