text
stringlengths
11
4.05M
package main // DupeFinder finds map keys sharing the same value. type DupeFinder struct{} // Find finds map keys which map to the same value. It returns a // multimap: keys are the duplicate values, values are sets containing // the original keys sharing the same value. func (df *DupeFinder) Find(m map[string]string...
package controllor import ( "crypto/md5" "encoding/hex" "encoding/json" "os" "strings" "xiaodaimeng/public" ) type SystemWxId struct { MaxAdminWxId string `json:"max_admin_wx_id"` //最大的微信管理员 NeedNoticeUpdateList []string `json:"need_notice_update_list"` //需要通知更新信息的id } var SystemWxIdList Sy...
package main import ( "testing" shared "github.com/corymurphy/adventofcode/shared" ) func Test_Part1(t *testing.T) { expected := 24 input := shared.ReadInput("input_test") actual := part1(input) shared.AssertEqual(t, expected, actual) } func Test_Part2(t *testing.T) { expected := 93 input := shared.ReadInpu...
// 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 main import ( "fmt" "strings" ) type Name struct { First, Last string } func fullName(n Name) string { return fmt.Sprintf("%s %s", n.First, n.Last) } func upper(n *Name) { n.First = strings.ToUpper(n.First) n.Last = strings.ToUpper(n.Last) } func main() { me := Name{"Nathan", "Youngman"} full := fu...
package entity import ( "github.com/mirzaakhena/danarisan/domain/service" "time" "github.com/mirzaakhena/danarisan/domain/vo" ) type Slot struct { BaseModel ID vo.SlotID `gorm:"primaryKey"` // ArisanID vo.ArisanID `json:"-"` // GroupSlotID vo.GroupSlotID `json:"-"` ...
package models type AitisiProslipsis struct { ID int `json:"id"` IDEmployee int `json:"idEmployee"` IDEmployer int `json:"idEmployer"` }
package list import "errors" // 循环链表 /* 注意点: 1. 删除的时候需要对是否是尾节点进行判断(如果是尾节点需要重新调整尾节点的指向) 2. 设定一个size变量来充当长度 3. 当遍历的时候,值是不可能为空的,因为是一个循环的链表,永远不会有空的指向,所以判断是否到头要通过判断是否与tail指针 相等 */ type CircularNode struct { data interface{} next *CircularNode } type CircularList struct { head *CircularNode tail *CircularNode ...
/* * @lc app=leetcode.cn id=1002 lang=golang * * [1002] 查找共用字符 */ package main import ( "sort" "strings" ) // @lc code=start func commonChars(words []string) []string { sort.Slice(words, func(i, j int) bool { return len(words[i]) < len(words[j]) }) counter := map[string]int{} for i := 0; i < len(words[0])...
package common // get args until arg is not empty func Def(args ...string) string { for _, v := range args { if v != "" { return v } } return "" }
package main import ( "fmt" "math" "strconv" "strings" ) // func compare(seats1, seats2 []string) bool { // if len(seats1) != len(seats2) { // return false // } // for i := range seats1 { // if seats1[i] != seats2[i] { // return false // } // } // return true // } // func getSeat(rows []string, x, ...
package scclient import ( "github.com/iotaledger/wasp/client/chainclient" "github.com/iotaledger/wasp/packages/coretypes" "github.com/iotaledger/wasp/packages/sctransaction" ) func (c *SCClient) PostRequest(fname string, params ...chainclient.PostRequestParams) (*sctransaction.Transaction, error) { return c.Chain...
package leetcode // TODO 动态规划 // 贪心 func maxProfit(prices []int) int { var minPirce int = prices[0] var max int for i := 0; i < len(prices); i++ { if prices[i] < minPirce { minPirce = prices[i] } if prices[i]-minPirce > max { max = prices[i] - minPirce } } return max } // 暴力 func maxProfit2(prices...
package routes import ( "fmt" "io/ioutil" "net/http" "github.com/davelaursen/idealogue-go/Godeps/_workspace/src/github.com/gorilla/mux" "github.com/davelaursen/idealogue-go/services" ) // RegisterUserRoutes registers the /users endpoints with the router. func RegisterUserRoutes(r *mux.Router, enc Encoder, userS...
// Unless explicitly stated otherwise all files in this repository are licensed // under the Apache License Version 2.0. // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-2019 Datadog, Inc. package strategy import ( "time" metav1 "k8s.io/apimachinery/pkg/apis/me...
package controllers import ( "lili_style_test/src/models" "lili_style_test/src/utils" ) func GetMentalityData(userdata []string) models.Mentality { answer := userdata[26:48] // はいで加点を整形 var yesAdd []string yesAdd = append(yesAdd,answer[1]) yesAdd = append(yesAdd,answer[4]) yesAdd = append(yesAdd,answer[9]) ...
/* * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. * Licensed under the MIT License (the "License"); you may not use this file except * in compliance with the License. You may obta...
package store import ( log "github.com/alecthomas/log4go" "github.com/alecthomas/tuplespace" "github.com/alecthomas/tuplespace/middleware" "time" ) // MemoryStore is an in-memory implementation of a TupleStore. It is mostly useful for testing. type MemoryStore struct { id uint64 tuples map[uint64]*tuplespac...
package models import ( "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mssql" _ "github.com/jinzhu/gorm/dialects/mysql" _ "github.com/jinzhu/gorm/dialects/postgres" _ "github.com/jinzhu/gorm/dialects/sqlite" "log" "os" ) var database *gorm.DB func GetDatabase() (*gorm.DB, error) { if database !=...
package middleware import ( "encoding/json" "github.com/bearname/videohost/internal/common/dto" "github.com/bearname/videohost/internal/common/util" "github.com/gorilla/context" log "github.com/sirupsen/logrus" "net/http" ) func LogMiddleware(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.R...
package mbclient import ( "encoding/xml" "fmt" "net/http" "net/http/httputil" "net/url" ) // MBClient describes parameters of a Musicbrainz client type MBClient struct { BaseURL *url.URL HTTPClient *http.Client UserAgent string } func (c *MBClient) CreateQuery() *url.Values { u := &url.URL{} q := u.Que...
// Copyright 2020, OpenTelemetry 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 ag...
package sese import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document03700104 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.037.001.04 Document"` Message *PortfolioTransferNotificationV04 `xml:"PrtflTrfNtfctn"` } func (d *Docu...
package pluginlocalp2pd import ( "context" "errors" "fmt" "io" "io/ioutil" "os" "os/exec" "path/filepath" "strconv" "strings" "syscall" "time" ma "gx/ipfs/QmNTCey11oxhb1AxDnQBRHtdhap6Ctud872NjAYPYYXPuc/go-multiaddr" peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" client "gx...
package main import ( "errors" "fmt" ) /* esds(Elementary Stream Descriptor) refer to: https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html#//apple_ref/doc/uid/TP40000939-CH205-124774 */ func (p *EsDescriptor) parseDescriptor(r *atomReader) error { _ = r.Move(4) // Versio...
package main import "fmt" func main() { // 虚假链表头 node0 := NewNode(nil) for i := 1; i <= 100; i++ { node0.Push(NewNode(i)) fmt.Println(i) } //fmt.Println(node0.pNext.pNext.pNext.data) //node0.Pop() //fmt.Println(node0.pNext.data) fmt.Println(node0.IsEmpty()) fmt.Println(node0.Length()) } type Node struc...
package marketplace import ( "crypto/ecdsa" "crypto/tls" "net" "sort" "sync" log "github.com/noxiouz/zapctx/ctxlog" "github.com/pborman/uuid" "github.com/pkg/errors" "github.com/sonm-io/core/insonmnia/structs" pb "github.com/sonm-io/core/proto" "github.com/sonm-io/core/util" "go.uber.org/zap" "golang.org...
package mapper import ( "database/sql" "github.com/fatih/structs" "github.com/xormplus/xorm" entity "mix/test/entity/core/transaction" "regexp" "mix/test/utils/mysql" ) func CreateAudit(session *xorm.Session, item *entity.Audit) (sql.Result, error) { return session.SqlMapClient("CreateAudit", item.Map()).Exec...
package main import ( "fmt" "regexp" "sort" "strconv" "strings" ) type group struct { side int units int hp int weaknesses map[string]bool immunities map[string]bool attackpower int attacktype string initiative int } func loaddata(input string) []group { gs := []group{} re :=...
package sleepy type PacketBuffer struct { buf SequenceBuffer entries []BufferedPacket } func NewPacketBuffer(cap uint16) *PacketBuffer { return &PacketBuffer{buf: NewSequenceBuffer(cap), entries: make([]BufferedPacket, cap, cap)} } func (s *PacketBuffer) IsOutdated(seq uint16) bool { return seqLessThan(seq, ...
package validator import ( "github.com/authelia/authelia/v4/internal/configuration/schema" ) // Test constants. const ( testInvalid = "invalid" testJWTSecret = "a_secret" testLDAPBaseDN = "base_dn" testLDAPPassword = "password" testLDAPURL = "ldap://ldap" testLDAPUser = "user" testEnc...
package lib import "testing" func TestHelloWorld(t *testing.T) { got := HelloWorld() want := "hello world" if want != got { t.Errorf("unexpected result. want: %s, got: %s", want, got) } }
package main import ( "bufio" "bytes" "io/ioutil" "log" "net/http" "os" ) type task struct { url string count int errorText string } // Do http get and count "Go" substrings in response func processTask(t *task) { resp, err := http.Get(t.url) if err != nil { t.errorText = err.Error() return ...
package dao import ( "errors" "git.dustess.com/mk-training/mk-blog-svc/pkg/blogstatistics/model" ) // ViewLogInsertOne 插入单条数据 func (m *BlogLogDao) ViewLogInsertOne(data model.ViewLogs) (string, error) { result, err := m.dao.InsertOne(m.ctx, data) if err != nil { return "", err } return result.InsertedID.(stri...
package olm import ( "strings" operatorsv1 "github.com/operator-framework/api/pkg/operators/v1" "github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/cache" ) type NamespaceSet map[string]struct{} func NewNamespaceSet(namespaces []string) NamespaceSet { set := make(Namespace...
package topics import ( "regexp" "strings" "github.com/go-git/go-git/v5/plumbing/object" ) type Topic struct { Name string ModifiedFiles map[string]*ModifiedFile } type ModifiedFile struct { Name string Path string FullName string Type string Commits []*CommitInfo } type CommitInfo ...
package common import "github.com/sony/sonyflake" var sf *sonyflake.Sonyflake func init() { sf = sonyflake.NewSonyflake(sonyflake.Settings{}) } func GenId() int64 { id, _ := sf.NextID() return int64(id) }
package acronym import ( "regexp" "strings" ) const testVersion = 1 func abbreviate(phrase string) string { words := regexp.MustCompile(`[A-Z]+[a-z]*|[a-z]+`) matches := words.FindAllString(phrase, -1) var initials string for _, match := range matches { initials += string(match[0]) } return strings.ToUpper...
// MIT License // // Copyright (c) 2017 Ryan Fowler // // 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,...
package main import ( "flag" "fmt" "golang.org/x/crypto/ssh/terminal" "io/ioutil" "net/http" "os" "strconv" ) func main() { port := 0 flag.IntVar(&port, "p", 8080, "port number(default:8080)") flag.Parse() if terminal.IsTerminal(0) { fmt.Println("pls send data over pipe.") } else { b, err := ioutil.Re...
package cp import ( "fmt" "io" "os" "golang.org/x/xerrors" ) type Destination struct { path string w io.WriteCloser } func (d *Destination) Write(p []byte) (n int, err error) { return d.w.Write(p) } func (d *Destination) Close() error { return d.w.Close() } // Create Destination struct func Dst(path st...
/* In architecture, an Atlas [https://atlas.hashicorp.com/] is a column or support sculpted in the form of a man; a Caryatid [https://github.com/mrled/packer-post-processor-caryatid] is such a support in the form of a woman. Caryatid is a packer post-processor plugin that provides a way to host a (versioned) Vagrant c...
package models import ( "database/sql" "git.hoogi.eu/snafu/go-blog/logger" "strings" "time" ) // SQLiteUserDatasource providing an implementation of UserDatasourceService using SQLite type SQLiteUserDatasource struct { SQLConn *sql.DB } // List returns a list of users func (rdb *SQLiteUserDatasource) List(p *Pa...
package omigad import ( "encoding/json" "log" "github.com/astaxie/beego" "github.com/astaxie/beego/context" "github.com/wst-libs/wst-sdk/sdk/manager" ) type CallBack struct { } type ReqBody struct { Id string `json:"id"` } type ResSuccess struct { Code int64 `json:"code"` } type ResFailed struct { Code int...
package main /** Support for times and durations */ import ( "fmt" "time" ) func main() { p := fmt.Println now := time.Now() // time now p(now) // can build a time strut then := time.Date(2009, 11, 17, 20, 34, 58, 651387237, time.UTC) p(then) // extract various components of the time value as expected p...
package main import ( "github.com/sipt/ngomc" "fmt" ) type A struct { A int64 B int32 C int8 D string E float64 F string G string H bool } func main() { a := &A{0, 1, 2, "abc", 1.1, "123", "ABC", false} fmt.Println(ngomc.Prepare(a)) bytes := ngomc.Encode(a) fmt.Println(bytes) b := &A{} b = ngomc.Deco...
package main import ( "flag" "fmt" "github.com/bagwanpankaj/zipper" ) func main() { var s = flag.String("s", "isgd", "specify service to use") var u = flag.String("u", "http://xyz.com", "specify url to shorten") var k = flag.String("k", "apikey", "specify api key") flag.Parse() z := zipper.New(*s, *...
package main import ( "fmt" "image" "image/color" "image/png" "math" "math/rand" "os" "rt1go/core" "runtime" "sync" "time" ) func calculateDirectLightingForAllLights(hit *core.HitRecord, lights *[]core.Hittable, scene *[]core.Hittable) core.Col3 { //foreach light in our list of lights outputColor := core...
package main //Write a function that add 1 to LinkedList number import ( "bytes" "fmt" ) type LL struct { head *Node tail *Node } func (l LL) String() string { var str bytes.Buffer n := l.head for n != nil { str.WriteString(fmt.Sprintf("%d", n.val)) n = n.next } return str.String() } type Node struct ...
package gpay import ( "bytes" "encoding/json" "github.com/ttooch/payment/helper" "io/ioutil" "time" "errors" "strings" "fmt" "github.com/google/uuid" ) const ( ChargeUrl = "https://jh.g-pay.cn/api/order.do" SUCCESS = "SUCCESS" ) type BaseCharge struct { *BaseConfig } type BaseConfig struct { ServiceN...
package seev import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document01300101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:seev.013.001.01 Document"` Message *AgentCAElectionAmendmentRequestV01 `xml:"AgtCAElctnAmdmntReq"` } func...
package main import ( "fmt" . "leetcode" ) //给定一棵二叉搜索树,请找出其中第 k 大的节点的值。 func main() { fmt.Println(kthLargest(NewTreeNode(3, 1, 4, 0, 2), 1)) } /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func kthLargest(root *TreeNode, k...
package Core import ( "container/list" "com/pdool/DataStruct" ) type Record struct { guid GUID // 对象id recordName string // 表名 maxRow int colProp DataStruct.Dictionary // 列名 :列类型 isSave bool // 是否保存 rows *DataStruct.LinkedList callbacks *list.List oldVar *DataStruct.L...
package nv4 import ( "context" "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/big" miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" cid "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-...
package xkblayout import ( "fmt" "github.com/rumpelsepp/i3gostatus/lib/model" ) var nextIndex int = 0 var prevIndex int = 0 var clickHandlers = &model.ClickHandlers{ HandleRightClick: onRightClick, HandleLeftClick: onLeftClick, } func determineIndexes(layouts []string) { for i, l := range layouts { if l ==...
package mgr import ( "encoding/json" "errors" "fmt" "io/ioutil" "net/http" "regexp" "sync" "sync/atomic" "github.com/Sirupsen/logrus" "github.com/jchprj/GeoOrderTest/cfg" "github.com/jchprj/GeoOrderTest/models" ) var autoID int64 var lock sync.RWMutex var isTest bool //Test use test mode func Test() { ...
package config const ( Manage_Job_ExeCute_Init_0 = 0 Manage_Job_ExeCute_Running_1 = 1 Manage_Job_ExeCute_Success_2 = 2 Manage_Job_ExeCute_Failed_3 = 3 Manage_Job_ExeCute_Timeout_4 = 4 ) const ( Manage_Job_Index_Order_Begain = 0 Manage_Job_All_Software = -1 ) func CheckJobExecuteState(executeState in...
package viewes import ( "fmt" ) const xml_ver string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" const open_tag string = "<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">" const close_tag string = "</sitemapindex>" type IndexXML struct { pages int host string } func NewIndexXML(pages int, ...
package lib import ( "crypto/md5" "encoding/hex" "fmt" "github.com/golang/glog" "math/big" "time" ) var Multiple float64 = 100 func MoneyIn(in float64) float64 { return Multiple * in } func MoneyOut(in float64) float64 { return in / Multiple } func Decimal(num float64) float64 { return float64(int(num*100...
/* * @lc app=leetcode.cn id=1732 lang=golang * * [1732] 找到最高海拔 */ // @lc code=start package main func largestAltitude(gain []int) int { ret := 0 if gain[0] > 0 { ret = gain[0] } for i := 1; i < len(gain); i++ { gain[i] += gain[i-1] if gain[i] > ret { ret = gain[i] } } return ret } // @lc code=e...
package main import ( "fmt" "io/ioutil" "strconv" "strings" ) func main() { s := read() part1(s) part2(s) } func part1(s string) { fmt.Println(process(s, 1)) } func part2(s string) { fmt.Println(process(s, len(s)/2)) } func process(s string, step int) int { sum := 0 bs := []byte(s) for i := 0; i < len(...
/* Package roleTypeRole "Every package should have a package comment, a block comment preceding the package clause. For multi-file packages, the package comment only needs to be present in one file, and any 7ne will do. The package comment should introduce the package and provide information relevant to the package as ...
package connrt import "github.com/gookit/event" type Node struct { eventManager event.ManagerFace }
package pkg const ( DEFAULT_HUB_ADDRESS = "https://hub.k0s.io" REDIR_PROXY_PORT = ":1081" SOCKS5_PROXY_PORT = ":1080" )
package main import "fmt" //func main() { // var s3,s4 string // fmt.Scan(&s3,&s4) // fmt.Println(&s3,&s4) // fmt.Println(s3,s4) // //} func main() { // 输入值并修改内存地址 var s3,s4 string fmt.Scan(&s3,&s4) fmt.Println(&s3,&s4) fmt.Println(s3,s4) // 根据输入的值计算圆的周长及面积 var r float64 const Pi = 3.1415926 fmt.Scan(&...
package main import ( "os" "fmt" "bufio" "io" "regexp" "strconv" "sort" "encoding/json" "time" "path/filepath" ) type Label struct { ClusterName string `json:"cluster_name"` ContainerName string `json:"container_name"` InstanceId string `json:"instance_id"` NamespaceId string `json:"namespace_id"...
package main /* * @lc app=leetcode id=110 lang=golang * * [110] Balanced Binary Tree */ /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func isBalanced(root *TreeNode) bool { return depth110(root) != -1 } ...
package azure import ( "testing" "github.com/Azure/azure-sdk-for-go/arm/resources/resources" ) type Resources struct { client resources.GroupsClient } func aborterr(t *testing.T, err error) { if err != nil { t.Fatal(err) } } func (r *Resources) AssertExists(t *testing.T, resourceName string) { _, err := r....
// Package fakenet contains fake implementations of interfaces from package net // from the standard library. // // It is recommended to fill all methods that shouldn't be called with: // // panic("not implemented") // // in the body of the test, so that if the method is called the panic backtrace // points to the meth...
// Package version enables setting build-time version using ldflags. package version import ( "fmt" "runtime" "strings" ) var ( // ProjectName is the canonical project name set by ldl flags ProjectName = "" // ProjectURL is the canonical project url set by ldl flags ProjectURL = "" // Version specifies Seman...
package gstreams type Record struct { key interface{} value interface{} }
package adapter import ( "reflect" "testing" "github.com/giantswarm/apiextensions/pkg/apis/provider/v1alpha1" ) func TestAdapterAutoScalingGroupRegularFields(t *testing.T) { t.Parallel() testCases := []struct { description string customObject v1alpha1.AWSConfig expecte...
// Package proxy provides an interface to a reverse-proxy that wraps the ego dev // server. The reverse-proxy has functionality to make development easier (like // automatically picking up file changes and displaying errors in the browser). package proxy import ( "log" "net/http" "net/http/httputil" "net/url" ...
package sprite import ( c "arkanoid/components" e "arkanoid/ecs" "sort" "github.com/hajimehoshi/ebiten" ) type spriteTransform struct { sprite *c.Sprite transform *c.Transform } // RenderSystem draw images. // Images are drawn in ascending order of depth. // Images with higher depth are thus drawn above im...
package controllers import ( "tokensky_bg_admin/enums" "tokensky_bg_admin/models" ) //用户邀请表 type TokenskyUserInviteContoller struct { BaseController } //Prepare 参考beego官方文档说明 func (c *TokenskyUserInviteContoller) Prepare() { //先执行 c.BaseController.Prepare() //如果一个Controller的多数Action都需要权限控制,则将验证放到Prepare c.che...
package reflection import ( "fmt" "reflect" "strconv" ) var ( numeric = []reflect.Kind{ reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Float32, reflect.Float64, } iteratable = [...
package main import ( "context" "fmt" "log" "net/http" "os" "github.com/gorilla/mux" "github.com/zmb3/spotify/v2" spotifyauth "github.com/zmb3/spotify/v2/auth" "golang.org/x/oauth2/clientcredentials" "github.com/Hozny/findipie/api" ) var MAX_REQUEST_SIZE = 1048576 func getRouter(ctx context.Context, spot...
/* Package interactive provides an easy to implement shell for simple, interactive commandline applications. It is build on top of the excellent https://golang.org/x/crypto/ssh/terminal package and tries to simplify the creation of small and simple applications which run in shell mode. It isn't very powerful (yet) but ...
package libs import ( "encoding/binary" "net" "errors" "fmt" ) type Packet interface { Serialize() []byte } type ZqProtocol struct { ToType int32 FromType int32 ToIp int32 FromIp int32 AskId int32 AskId2 int32 } type ZqPacket struct { Header ZqProtocol Body string } func (z *ZqPacket) Serialize() []byt...
// Copyright (c) 2020 Blockwatch Data Inc. // Copyright (c) 2013-2015 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package base58 import ( "math/big" "sync" ) //go:generate go run genalphabet.go var bigIntPool = &sync.Pool{ New: func()...
package v1alpha1 import ( "testing" next "github.com/devspace-cloud/devspace/pkg/devspace/config/versions/v1alpha2" "github.com/devspace-cloud/devspace/pkg/util/log" "github.com/devspace-cloud/devspace/pkg/util/ptr" ) func TestEmpty(t *testing.T) { oldConfig := New() oldConfigConverted := oldConfig.(*Config) ...
package tak const ( MAGIC_NUM byte = 0xbf )
func longestPalindrome(s string) string { if len(s) == 0{ return "" } if len(s) == 1{ return s } start, end, maxlen := 0, 0, 0 for idx := 0; idx < len(s); idx += 1{ left, right := idx, idx for right + 1 < len(s) && s[right + 1] == s[left]{ right += 1 ...
package test import ( uuid "github.com/satori/go.uuid" ) func theAccountExistsWithUUID(u string) error { stmt := ` INSERT INTO public."Account" (id,organisation_id,"version",is_deleted,is_locked,created_on,modified_on,record) VALUES ('` + u + `'::uuid, '` + u + `'::uuid,0,false,false,'2021-01-01 11:11:11.123456...
// 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...
package main import ( "encoding/json" "flag" "fmt" "io/ioutil" "net/http" "os" "strings" ) var ( nodeIp string nodePort string ) var metrics struct { Indices struct { Docs struct { Count int64 `json:"count"` } `json:"docs"` } `json:"indices"` Nodes struct { Fs struct { TotalInBytes int6...
package cmd import ( "fmt" "os" "github.com/Sirupsen/logrus" "github.com/jchprj/GeoOrderTest/api" "github.com/jchprj/GeoOrderTest/cfg" "github.com/jchprj/GeoOrderTest/mgr" "github.com/spf13/cobra" ) var cfgFile string func init() { cobra.OnInitialize(finishInit) rootCmd.PersistentFlags().StringVar(&cfgFil...
package filter import "net/http" // 前置过滤器,用于跨域 func Cors(w http.ResponseWriter, r *http.Request, m map[string]interface{}) bool { w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Access-Control-Request-Method", "GET, POST, DELETE, PUT") w.Header().Set("Access-Control-Allow-Headers", "Origin, X-Re...
package security import ( "errors" "sync" ) var ( ErrRoleNotExist = errors.New("Role does not exist") ErrRoleExist = errors.New("Role has already existed") ) type Role interface { Name() string Permit(Permission) bool Assign(Permission) error Revoke(Permission) error } type Roles map[string]Role type St...
package concurrent import "sync" func Go(f FuncWithResultMayError, options ...GoOption) { var goOptions GoOptions for _, option := range options { if option != nil { option(&goOptions) } } for _, w := range goOptions.wrappers { f = w(f) } if goOptions.skipNilFunc && f == nil { return } if goOptions...
package util import ( "bytes" "encoding/binary" "encoding/gob" "fmt" . "server/data/datatype" ) type StoreArchive struct { buffer *bytes.Buffer } func NewStoreArchiver(data []byte) *StoreArchive { ar := &StoreArchive{} ar.buffer = bytes.NewBuffer(data) return ar } func (ar *StoreArchive) Data() []byte { r...
package controllers import ( "errors" "net/url" "reflect" "strconv" "time" "github.com/kdada/tinygo" ) // BaseController 基础controller type BaseController struct { tinygo.Controller } // ParseForm 参数解析 func (b *BaseController) ParseForm(params ...interface{}) error { var f, _ = b.Context.ParamFile() f.SaveT...
package main import ( "fmt" "log" "mime" ) func main() { fmt.Println("vim-go") src := "您好!" fmt.Printf("src : %#v\n", src) strutf8 := mime.QEncoding.Encode("utf-8", src) fmt.Printf("strutf8: %#v\n", strutf8) dec := new(mime.WordDecoder) str, err := dec.Decode(strutf8) if err != nil { log.Fatal(err) } ...
package polls import ( "fmt" "log" "os" "github.com/Nv7-Github/Nv7Haven/eod/types" "github.com/bwmarrin/discordgo" ) func (b *Polls) RejectPoll(dat types.ServerData, p types.Poll, messageid, user string) types.ServerData { dat.Lock.Lock() delete(dat.Polls, messageid) dat.Lock.Unlock() b.db.Exec("DELETE FRO...
//////////////////////////////////////////////////////////////////////////////// // // // Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or // // its subsidiaries. ...
package main import ( "fmt" "github.com/jnewmano/advent2020/input" "github.com/jnewmano/advent2020/output" ) func main() { sum := parta() fmt.Println(sum) } func parta() interface{} { //input.SetRaw(raw) // var things = input.Load() acc := 0 var things = input.LoadSliceString("") for i := 0; i < len(th...
package main import ( "encoding/json" "fmt" "net/http" jwt "github.com/dgrijalva/jwt-go" ) type UserPayload struct { Name string `json:"name"` Email string `json:"email"` Password string `json:"password"` } type UserResponse struct { ID uint `json:"id"` Name string `json:"name"` Email string ...
package rtrserver import ( "encoding/hex" "fmt" "testing" "github.com/cpusoft/goutil/convert" "github.com/cpusoft/goutil/jsonutil" ) func TestRtrPdu(t *testing.T) { erm := NewRtrErrorReportModel(0, 1, nil, nil) fmt.Println(jsonutil.MarshalJson(erm)) fmt.Println(hex.Dump(erm.Bytes())) fmt.Println(convert.Pri...
package user import ( "fmt" "github.com/globalsign/mgo/bson" ) func (userModel *UserModel) addFans(uid, subUid bson.ObjectId) (err error) { c := userModel.GetC() defer c.Database.Session.Close() return c.UpdateId( uid, bson.M{"$push": bson.M{"fans_users": subUid}}, ) } func (userModel *UserModel) removeFa...
package main import ( "fmt" "net/http" "strconv" "strings" ) func main() { var err error var resp *http.Response for i := 0; i < 100; i++ { if resp, err = http.Get("http://app:8080/"); err != nil { panic(err) } fmt.Println("-- Response " + strconv.Itoa(resp.StatusCode)) for k, v := range resp.Heade...