text
stringlengths
11
4.05M
package moxxiConf import ( "bufio" "bytes" "fmt" "io/ioutil" "log" "net/http" "net/http/httptest" "net/url" "os" "strings" "testing" "text/template" "github.com/stretchr/testify/assert" ) func TestStaticHandler(t *testing.T) { // test setup expected := []byte(`this is the response I expect to recieve`...
package utils import ( "errors" "github.com/wenzhenxi/gorsa" ) var publicKey = `-----BEGIN 公钥----- MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANL378k3RiZHWx5AfJqdH9xRNBmD9wGD2iRe41HdTNF8RUhNnHit5NpMNtGL0NPTSSpPjjI1kJfVorRvaQerUgkCAwEAAQ== -----END 公钥----- ` var privateKey = `-----BEGIN 私钥----- MIIBUwIBADANBgkqhkiG9w0BAQEFAAS...
package cmd import ( "bufio" "encoding/json" "fmt" "io" "io/ioutil" "log" "net/http" "os" "path/filepath" "sort" "strings" "time" "github.com/hoisie/mustache" "github.com/mitchellh/go-homedir" ) const ( appName = "rest-client" defaultEnvFile = "rest-client.env.json" httpFileExt = ".http" ...
package helm import ( "github.com/devspace-cloud/devspace/pkg/devspace/config/generated" "github.com/devspace-cloud/devspace/pkg/devspace/config/versions/latest" "github.com/devspace-cloud/devspace/pkg/devspace/deploy/deployer" "github.com/devspace-cloud/devspace/pkg/devspace/helm" helmtypes "github.com/devspace-...
package main import ( "fmt" "os" "github.com/vlad-belogrudov/gopl/pkg/space" ) func main() { if len(os.Args) < 2 { fmt.Fprintln(os.Stderr, `need word to brush, e.g "hello bye end"`) os.Exit(1) } fmt.Println(string(space.Brush([]byte(os.Args[1])))) }
package website import ( "classes/oop/blog/post" "fmt" ) type website struct { p []post.Post } //Website exports website type Website website //New creates website object func New(args ...interface{}) Website { var w Website wArgs := make([]string, 0) for i, v := range args { wArgs = append(wArgs, fmt.Sprin...
package form import ( "fmt" "log" "net/url" "reflect" "strconv" "time" ) const ( errArraySize = "Array size of '%d' is larger than the maximum currently set on the decoder of '%d'. To increase this limit please see, SetMaxArraySize(size uint)" errMissingStartBracket = "Invalid formatting for key '%s...
package shufflearray func removeIndex(nums []int, i int) []int { return append(nums[:i], nums[i+1:]...) } func insertIndex(nums []int, i int, v int) []int { nums = append(nums, 0) copy(nums[i+1:], nums[i:]) nums[i] = v return nums } func shuffle(nums []int, n int) []int { for i := 0; i < n; i++ { v := nums[n...
package action import ( "github.com/agiledragon/trans-dsl" "github.com/agiledragon/trans-dsl/test/context" ) type StubModifySomething struct { } func (this *StubModifySomething) Exec(transInfo *transdsl.TransInfo) error { stubInfo := transInfo.AppInfo.(*context.StubInfo) stubInfo.P2 = 22 return nil } func (thi...
package main import "sync" func main() { } func findDifference(nums1 []int, nums2 []int) [][]int { m1 := make(map[int]bool) m2 := make(map[int]bool) for _, v := range nums1 { m1[v] = true } for _, v := range nums2 { m2[v] = true } ans := make([][]int, 2) var wg sync.WaitGroup wg.Add(2) go func() ...
package main import ( "fmt" ) func test() { // go 数组为之类型 不是引用传递 //长度为2的int数字 默认是0 //不同长度的数组是不同的类型 //长度也是数组的一部分 var a [2]int //var c [1]int //自动长度,9+1 b := [...]int{9: 1} //返回一个指向数组的指针 p := new([10]int) //多维数组 有两个元素,每个元素又是有3个int的数组 var d [2][3]int fmt.Println(a) fmt.Println(b) fmt.Println(p) fmt.Pri...
package protocol import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Stream ID", func() { Context("bidirectional streams", func() { It("doesn't allow any", func() { Expect(MaxBidiStreamID(0, PerspectiveClient)).To(Equal(StreamID(0))) Expect(MaxBidiStreamID(0, PerspectiveServe...
//+build !noexit /* * Copyright (c) Microsoft Corporation. * Licensed under the MIT license. */ package xcobra import ( "errors" "os" ) func exitWithCode(err error) { if err == nil { return } var e ErrorWithCode if errors.As(err, &e) { os.Exit(e.Code) } os.Exit(1) }
package dbops import ( "database/sql" _ "github.com/go-sql-driver/mysql" "time" ) var ( dbConn *sql.DB err error ) func init() { dbConn, err = sql.Open("mysql", "root:llc123..@tcp(106.14.146.41:3306)/ynk_cms?charset=utf8&parseTime=True&loc=Local") if err != nil { panic(err.Error()) } //设置连接的最大连接周期,超时自动...
package engine import ( "encoding/json" "testing" "time" . "github.com/mailgun/vulcand/Godeps/_workspace/src/gopkg.in/check.v1" "github.com/mailgun/vulcand/plugin" "github.com/mailgun/vulcand/plugin/connlimit" ) func TestBackend(t *testing.T) { TestingT(t) } type BackendSuite struct { } var _ = Suite(&Backen...
/** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func getIntersectionNode(headA, headB *ListNode) *ListNode { node1, node2 := headA, headB for node1 != node2 { if node1 != nil { node1 = node1.Next } else { ...
package honeycombio import ( "context" "errors" "fmt" "testing" "time" "github.com/stretchr/testify/assert" ) func TestTriggers(t *testing.T) { ctx := context.Background() var trigger *Trigger var err error c := newTestClient(t) dataset := testDataset(t) t.Run("Create", func(t *testing.T) { data := ...
package zen import "fmt" func Show(msg string) error { fmt.Println("Hello, %s!", msg) return nil }
// +build !darwin package platform func start(h *CursorHandle) {}
package main import ( "encoding/json" "flag" "fmt" "log" "os" "strings" ) var ( graphfile = flag.String("graphfile", "kevinbacon.json", "graph data file") ) func main() { flag.Usage = usage flag.Parse() if flag.NArg() < 1 { usage() } graph, err := load(*graphfile) if err != nil { log.Fatal(err) } ...
package controller import ( "fmt" "log" "net/http" "github.com/SebastiaanKlippert/go-wkhtmltopdf" "github.com/gin-gonic/gin" ) // DownloadPdf 通过html url地址下载pdf附件 func DownloadPdf(c *gin.Context) { url := c.Query("url") if url == "" { c.JSON(http.StatusBadRequest, gin.H{ "msg": "url is empty", }) } p...
/* * Copyright (c) 2018 Jeffrey Walter <jeffreydwalter@gmail.com> * * 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, c...
package tools_test import ( "testing" "payment/internal/tools" "github.com/stretchr/testify/assert" ) func TestIsExistSlice(t *testing.T) { var ( payload = []struct { want bool got string }{ {true, "test1"}, {false, "test66"}, } slice = []string{ "test1", "test2", "test3", } ) t.Run(...
package main import ( "fmt" ) type teste int var x teste var y int func main() { fmt.Printf("tipo:%T\nvalor:%v\n", x, x) x = 42 fmt.Printf("x:%d\n", x) y = int(x) fmt.Printf("valor de y:%v\ntipo de y:%T\n", y, y) }
package main import ( "bytes" "crypto/tls" "encoding/base64" "encoding/json" "flag" "fmt" "io/ioutil" "log" "net/http" "net/url" "strings" "time" "github.com/gorilla/mux" ) var ( bind = flag.String( "bind", "127.0.0.1:8080", "Listening address for incoming requests", ) concourseUrl = flag.Strin...
package problem0166 import ( "strconv" ) func fractionToDecimal(numerator int, denominator int) string { result := "" // 处理符号位 digit := "" if (numerator > 0 && denominator < 0) || (numerator < 0 && denominator > 0) { digit = "-" } result += digit // 整数部分 numerator = abs(numerator) denominator = abs(denom...
// Copyright 2023 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 main import ( "database/sql" "fmt" _ "github.com/lib/pq" "github.com/op/go-logging" "os" "runtime" "strconv" ) // CheckEnvVars checks that all the environment variables required are set, without checking their value. It will panic if one is missing. func CheckEnvVars() { envvars := []string{"AWS_ACCES...
package errors import ( "encoding/json" "errors" "testing" "github.com/rs/zerolog" ) func TestError_UnmarshalJSON(t *testing.T) { t.Run("no bytes", func(t *testing.T) { e := &Error{ Err: errors.New("test error"), Op: "testOp", Kind: KindUnexpected, Level: zerolog.TraceLevel, } err := e....
package git import ( "errors" "io/ioutil" "os" "os/exec" "path/filepath" "strings" log "github.com/sirupsen/logrus" "golang.org/x/crypto/ssh" "gopkg.in/src-d/go-git.v4" "gopkg.in/src-d/go-git.v4/config" "gopkg.in/src-d/go-git.v4/plumbing/transport" "gopkg.in/src-d/go-git.v4/plumbing/transport/http" ssh2 ...
func rob(nums []int) int { if len(nums) == 0{ return 0 } if len(nums) == 1{ return nums[0] } max_v := make([]int, len(nums)) for idx := 0; idx < len(nums); idx += 1{ if idx == 0{ max_v[idx] = nums[0] } else if idx == 1{ max_v[idx] = max(num...
package model type account struct { account_num string account_currency string } type request struct { inn string bank_branch_inn string doc_date string doc_num string bank_branch_director string bank_branch_operator string authCode ...
package pattern import "fmt" type WithName struct { Name string } type Country struct { WithName } type City struct { WithName } func (w WithName) PrintStr() { fmt.Println(w.Name) } type Shape interface { Sides() int Area() int } type Square struct { Len int } func (s Square) Sides() int { return 4 } f...
package relay import ( "net" "strconv" ) // TCPRelayConn is the wrapper of // net.Conn used for tcp relay. type TCPRelayConn struct { net.Conn relay *TCPRelay } // Close rewrite the Close method of net.Conn, // it put the nat port back to nat pool after // conn closed. func (conn TCPRelayConn) Close() error { /...
package subscription import ( "context" "encoding/json" "fmt" "time" "github.com/google/uuid" "github.com/imrenagi/go-payment" "github.com/imrenagi/go-payment/invoice" ) // New creates empty subscription with valid UUID func New() *Subscription { return &Subscription{ Number: uuid.New().String(), // TODO...
package api import ( "net/http" "time" "github.com/gorilla/mux" "github.com/pkg/errors" "github.com/rancher/go-rancher/api" "github.com/rancher/go-rancher/client" "github.com/rancher/longhorn-manager/types" "github.com/rancher/longhorn-manager/util" ) func (s *Server) ListVolume(rw http.ResponseWriter, req ...
/** *@Author: haoxiongxiao *@Date: 2019/3/20 *@Description: CREATE GO FILE admin */ package admin import ( "bysj/models" "bysj/services" "github.com/kataras/iris" "github.com/spf13/cast" ) type OrderController struct { Ctx iris.Context Service *services.OrderService Common } func NewOrderController() *Ord...
package main import ( "fmt" "math" ) // Converter measures distance type Converter struct{} // Feet measures distance type Feet float64 // Centimeter measures distance type Centimeter float64 // Minutes measures time type Minutes float64 // Seconds measures time type Seconds float64 // Celsius measures tempera...
package main import ( "github.com/julianshen/gopttcrawler" "log" ) func main() { alist, _ := gopttcrawler.GetArticles("Beauty", 0) for _, a := range alist.Articles { log.Println(a.Title) } nextpage, err := alist.GetFromPreviousPage() if err != nil { panic(err) } for _, a := range nextpage.Articles { ...
package main import ( "bufio" "fmt" "html" "io/ioutil" "log" "net/http" "net/url" "os" "strings" "time" "os/exec" "github.com/bitly/go-simplejson" "github.com/boltdb/bolt" ) var bucketName = "BGMReport" func HandleError(err error) { if err != nil { log.Fatal(err) } } func main() { // Database db...
// ˅ package main // ˄ type Command struct { // ˅ // ˄ node INode // ˅ // ˄ } func NewCommand() *Command { // ˅ return &Command{} // ˄ } func (self *Command) Parse(context *Context) { // ˅ if context.GetToken() == "repeat" { self.node = NewRepeat() } else { self.node = NewAction(context.GetToken(...
package blob import ( "context" "gocloud.dev/blob" "io" ) // Bucket embeds the original blob.Bucket for providing compatible storage.Storage interface methods type Bucket struct{ *blob.Bucket } // Download provides compatible Download method of the storage.Storage interface func (b *Bucket) Download(ctx context.C...
// // Package simpleflag is useful for creating command line Go applications. // // Limitations // // No arguments are managed, only flags. // The App must have subcommands. // // Configuration // // App is the main structure of the cli application. // The App has a list of Commands. // Each command has a list of Flags...
// Package ciolite is the Golang client library for the Lite Context.IO API package ciolite //go:generate mockgen -source ciolite.go -destination ciolite_mock.go -package ciolite import ( "crypto/hmac" "crypto/sha256" "encoding/hex" "hash" "net/http" "net/http/httptest" "net/url" "strconv" "time" ) const ( ...
package dictionary // import( // "github.com/Evedel/fortify/src/say" // ) func ruleOperand(ttail []Token) (resCode int, stopInd int, resNode TokenNode, errmsg string) { errmsg = "ruleOperand: " resCode = UndefinedError stopInd = 0 index := 0 chStopIndx := 0 rhs := TokenNodeRightHS() for index < len(ttail) {...
package personages import ( "core/sessions" "fmt" "net/http" "qutils/basehandlers" "qutils/coder" ) func CreatePersonageHandler(resp http.ResponseWriter, req *http.Request) { defer req.Body.Close() session, ok := sessions.GetSessionByRequest(req) if !ok { basehandlers.UnauthorizedRequest(resp, req) return...
package main import ( "fmt" polon "github.com/pharrisee/poloniex-api" ) func main() { p := polon.NewWithCredentials("Key goes here", "secret goes here") fmt.Println(p) // p.Subscribe("ticker") // p.Subscribe("USDT_BTC") // p.On("ticker", func(m polon.WSTicker) { // pp.Println(m) // }).On("USDT_BTC-trade",...
package controllers import ( "goapi/models" "html/template" "log" "net/http" "strconv" ) var templates = template.Must(template.ParseGlob("templates/*.html")) func Index(w http.ResponseWriter, r *http.Request) { products := models.GetProducts() templates.ExecuteTemplate(w, "Index", products) } func New(w htt...
package utils import ( "encoding/json" "log" ) func ToJSON(o interface{}) string { b, err := json.Marshal(o) if err != nil { log.Print(err) } return string(b) }
//go:build go1.21 package indenthandler import ( "context" "fmt" "io" "log/slog" "runtime" "slices" "strconv" "sync" "time" ) // !+IndentHandler type IndentHandler struct { opts Options preformatted []byte // data from WithGroup and WithAttrs unopenedGroups []string // groups from WithGroup...
package models //Тип для парсинга request/response type JsonUrl struct { Url string `json:"url"` }
package main import "fmt" func main() { myMap := map[string]string{ "1": "一", "2": "二", "3": "三", } fmt.Println("原始地图") for k := range myMap { fmt.Println(k, "首都是", myMap[k]) } delete(myMap, "3") fmt.Println("=======删除3=======") for k := range myMap { fmt.Println(k, "首都是", myMap[k]) } }
package models type Unit struct { UnitId int `json:"unitId,omitempty" db:"UnitId"` UnitNamePl string `json:"unitNamePl" db:"UnitNamePl"` UnitNameEn string `json:"unitNameEn" db:"UnitNameEn"` QuantityId int `json:"quantityId" db:"QuantityId"` Ratio float32 `json:"ratio" db:"Ratio"...
import "strconv" func numDecodings(s string) int { ls := len(s) if ls == 0 { return 0 } else if ls == 1 { if isValid(s) { return 1 } else { return 0 } } nums := make([]int, len(s)) if isValid(s[0:1]) { nums[0] = 1 } if isValid(s[1:2]) { nums[1] = nums[0] } if isValid(s[0:2]) { nums[1] += ...
package nmxutil import ( "sync" ) type Bcaster struct { chs [](chan interface{}) mtx sync.Mutex } func (b *Bcaster) Listen() chan interface{} { b.mtx.Lock() defer b.mtx.Unlock() ch := make(chan interface{}) b.chs = append(b.chs, ch) return ch } func (b *Bcaster) Send(val interface{}) { b.mtx.Lock() chs ...
package main import ( "fmt" "os" "os/exec" "strings" ) var cmdPs = &Command{ Name: "ps", Description: "List all conair containers", Summary: "List all conair containers", Run: runPs, } func runPs(args []string) (exit int) { path, err := exec.LookPath("machinectl") if err != nil { fmt....
/* Copyright 2017 The Rook Authors. 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 law or agreed to ...
package matchserver import ( "context" "errors" "log" "math/rand" "strconv" "sync" "time" pb "github.com/ekotlikoff/gochess/api" "github.com/ekotlikoff/gochess/internal/model" "github.com/prometheus/client_golang/prometheus" "google.golang.org/grpc" ) var ( // PollingDefaultTimeout is the default timeout...
package swap import ( "bytes" "context" "encoding/binary" "errors" "fmt" bin "github.com/gagliardetto/binary" "github.com/gagliardetto/solana-go" "github.com/gagliardetto/solana-go/programs/system" "github.com/gagliardetto/solana-go/programs/token" "github.com/gagliardetto/solana-go/rpc" "github.com/gopart...
package collection import ( "math" "github.com/tidwall/tile38/internal/object" ) func geodeticDistAlgo(center [2]float64) ( algo func(min, max [2]float64, obj *object.Object, item bool) (dist float64), ) { const earthRadius = 6371e3 return func(min, max [2]float64, obj *object.Object, item bool) (dist float64) ...
package main import ( "fmt" ) type TZ int type A struct { name string } func main() { a := A{} a.Print() fmt.Println(a.name) var tz TZ tz.Increase(100) fmt.Println(tz) } func (a *A) Print() { a.name = "122" fmt.Println("A") } func (tz *TZ) Increase(num int) { *tz += TZ(num) }
package tasks_test import ( "testing" "github.com/stretchr/testify/assert" "go.ua-ecm.com/chaki/tasks" ) func TestValidate(t *testing.T) { assert := assert.New(t) task := &tasks.Task{ Schema: map[string]interface{}{ "properties": map[string]interface{}{ "number": map[string]interface{}{ "title":...
package orm import ( "database/sql" "errors" ) // result is a pointer (eg. &[]struct or &[]*struct) func Find(db *sql.DB, result interface{}, query string, args ...interface{}) (affectedRows int64, err error, closeErr error) { if db == nil { err = errors.New("db can't be nil") return } rows, err := db.Query...
package discountsrv import ( "context" "github.com/amanbolat/furutsu/datastore" "github.com/amanbolat/furutsu/internal/cart" "github.com/amanbolat/furutsu/internal/discount" ) type Service struct { repo datastore.Repository } func NewService(repo datastore.Repository) *Service { return &Service{repo: repo} } ...
/* // Authors: Rajagopalan Ranganathan (rajagopalan.ranganthan@aalto.fi) Sunil Kumar Mohanty (sunil.mohanty@aalto.fi) The following source code, has been created for academic purpose to experiment and use a custom Kubernetes container scheduler logic. It iterates through the PODs and assigns a Node ...
package observer import "fmt" type concretePublisher struct { observers []Observer } // Attach pins an Observer to the publisher (implements Publisher interface) func (p *concretePublisher) Attach(obs Observer) { p.observers = append(p.observers, obs) } // Notify notifies all of the Publisher's observers (impleme...
/* * @lc app=leetcode.cn id=704 lang=golang * * [704] 二分查找 */ // @lc code=start package main import "fmt" func search(nums []int, target int) int { if len(nums) == 0 { return -1 } down := 0 upper := len(nums) -1 var mid int for down <= upper { mid = down+((upper-down)>>1) // fmt.Printf("%d, %d, %...
package main import ( "fmt" ) func main() { f2(f1()) } func f1() (int, string, float32) { return 0, "xzy", 3.14 } func f2(a int, b string, c interface{}) { fmt.Println(a, b, c) }
package LeetCode import "math" func SortArrayByParityII(A []int) []int { result := make([]int,len(A)) p1,p2 := 0, 1 for _,v := range A { if int(math.Mod( float64(v), float64(2) )) == 0 { result[p1] = v p1+=2 } else { result[p2] = v p2+=2 } } return result }
// Copyright (C) 2016 Lukas Lalinsky // Distributed under the MIT license, see the LICENSE file for details. package main import ( "bufio" "encoding/binary" "flag" "fmt" "github.com/acoustid/go-acoustid/util" "github.com/pkg/errors" "io" "log" "os" ) func readBlockIndex(name string) ([]uint32, error) { fi...
package equinix import ( "fmt" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) const tstL2SellerProfileEnvVar = "TF_ACC_ECX_SELLER_PROFILE_NAME" func TestAccECXL2SellerProfile(t *testing.T) { t.Parallel() profileName, _ :=...
package auth import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document01000101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:auth.010.001.01 Document"` Message *RegulatoryTransactionReportStatusV01 `xml:"RgltryTxRptStsV01"` } fu...
package service import ( "github.com/openshift/odo/pkg/odo/util/validation" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // ServiceInfo holds all important information about one service type Service struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` Spec Ser...
package controllers_test import ( "authentication/controllers" "authentication/router" "net/http" "net/http/httptest" "testing" "authentication/models" "bytes" "encoding/json" . "github.com/smartystreets/goconvey/convey" ) // TestStatusRoute func TestLoginRoute(t *testing.T) { db := models.SetupModels() ...
// Copyright 2016-2021, Pulumi Corporation. package schema import ( "regexp" "testing" "github.com/stretchr/testify/assert" jsschema "github.com/lestrrat-go/jsschema" "github.com/pulumi/pulumi/pkg/v3/codegen" pschema "github.com/pulumi/pulumi/pkg/v3/codegen/schema" ) type PropertyTypeSpecTestCase struct { j...
package statistics import ( "math" "sync" "time" "github.com/matrix-org/dendrite/federationsender/storage" "github.com/matrix-org/gomatrixserverlib" "github.com/sirupsen/logrus" "go.uber.org/atomic" ) // Statistics contains information about all of the remote federated // hosts that we have interacted with. I...
package main import ( "fmt" ) /** * 汉诺塔,经典的递归游戏,最短步数为 (2^n) -1 , n 是盘子数量 * 把大象搬到冰箱里只要 3 步 打开冰箱门, 把大象装进去, 把冰箱门关上。 */ const DiskNum = 5 func main() { hanoi_0(DiskNum, "a", "b", "c") fmt.Printf("disk num: %d, min step: %d", DiskNum, times) } func hanoi_0(n int, a string, b string, c string) { if (n < 1) { fmt....
package domain import ( "time" "github.com/gofrs/uuid" ) type TaskService interface { FindAreaByID(uid uuid.UUID) ServiceResult FindCropByID(uid uuid.UUID) ServiceResult FindMaterialByID(uid uuid.UUID) ServiceResult FindReservoirByID(uid uuid.UUID) ServiceResult } // ServiceResult is the container for service...
package main import ( "github.com/superboy724/wechatmessage/processer" "github.com/superboy724/wechatmessage/server" ) func main() { server := server.NewServer(80) p := processer.NewMessageProcesser() server.SetProcesser(p) server.Run() }
// Copyright ©2012 The bíogo Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package kmeans_test import ( "math/rand" "strings" "testing" "github.com/biogo/cluster/cluster" "github.com/biogo/cluster/kmeans" "gopkg.in/check.v...
package main import ( "encoding/json" "log" "net/http" "strings" "io/ioutil" "flag" "path/filepath" "regexp" "github.com/julienschmidt/httprouter" // "github.com/k0kubun/pp" ) var ConfigDirectory = flag.String("c", ".", "Configuration directory (default .)") type Message struct { Status stri...
/* * Copyright 2017 StreamSets 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...
package crawl import "github.com/golang/glog" const ( _ glog.Level = iota SegmentI LineI TypingI HttpI LogI SegmentD LineD TypingD HttpD LogD SegmentV LineV TypingV HttpV LogV )
package atomix import ( "sync/atomic" "unsafe" ) // AddInt is same as [atomic.AddInt32] or [atomic.AddInt64] but for int type. func AddInt(addr *int, delta int) (new int) { switch unsafe.Sizeof(*addr) { case 4: return int(atomic.AddInt32((*int32)(unsafe.Pointer(addr)), int32(delta))) case 8: return int(atomi...
package dao import ( "fmt" "github.com/go-redis/redis" _ "github.com/go-sql-driver/mysql" "github.com/jmoiron/sqlx" "moriaty.com/cia/cia-supporter/config" ) /** * @author 16计算机 Moriaty * @version 1.0 * @copyright :Moriaty 版权所有 © 2020 * @date 2020/4/7 11:08 * @Description TODO * dao 初始化 */ var ( DB *sql...
package main import ( "log" "net/http" "os" "encoding/json" gp "github.com/jayluxferro/ghanapostgps" "github.com/gin-gonic/gin" _ "github.com/heroku/x/hmetrics/onload" "strings" ) var params gp.Params const identifier = "CenterLatitude" type DataResponse struct { Table []Info } type Info struct { Are...
package certs import ( "crypto/ecdsa" "crypto/elliptic" "crypto/rand" "crypto/sha256" "crypto/x509" "crypto/x509/pkix" "encoding/hex" "encoding/pem" "fmt" "math" "math/big" "time" ) type CertGenerator interface { Generate(notAfter time.Time, organization string, ca *KeyPair, hosts []string) (*KeyPair, er...
package service import ( "github.com/gorilla/mux" "github.com/the-gigi/delinkcious/pkg/db_util" "log" "net/http" httptransport "github.com/go-kit/kit/transport/http" lm "github.com/the-gigi/delinkcious/pkg/link_manager" sgm "github.com/the-gigi/delinkcious/pkg/social_graph_client" ) func Run() { dbHost, dbPo...
package main import "fmt" func main() { xs := filter([]int{1, 4, 6, 7, 8, 9, 10, 11, 17, 21, 23}, func(n int) bool { return n > 1 }) fmt.Println(xs) } func filter(numbers []int, callback func(int) bool) []int { var xs []int for _, n := range numbers { if callback(n) { xs = append(xs, n) } } return...
package pretty_poly import "testing" import "github.com/franela/goblin" type toMixedRadixTestCase struct { bases [ ]int num int } func BenchmarkToMixedRadix (bench *testing.B) { bases := [ ] int {100, 100, 100, 100, 100} bench.StartTimer( ) for ith := 0; ith < bench.N; ith++ { toMixedRadix(ba...
package nimkv import ( "errors" "sync" "time" ) type Cacher interface { IsItemPresent(string) bool GetItem(string) (*cacheItem, error) GetAllItems() *cacheItems DeleteItem(string) error SetItemWithExpiry(string, interface{}, time.Duration) SetItem(string, interface{}) Purge() } // CacheBase struc...
// This file was generated for SObject NamedCredential, API Version v43.0 at 2018-07-30 03:47:20.867565454 -0400 EDT m=+7.210442449 package sobjects import ( "fmt" "strings" ) type NamedCredential struct { BaseSObject AuthProviderId string `force:",omitempty"` CalloutOptionsAllowMerge...
package web import ( "fmt" "github.com/gofiber/fiber/v2" "github.com/gofiber/session/v2" "github.com/google/uuid" "github.com/iamtraining/forum/entity" "github.com/iamtraining/forum/store" "golang.org/x/crypto/bcrypt" ) var sessions *session.Session type UserHandler struct { store *store.Store } func init(...
// Copyright © 2018 Inanc Gumus // Learn Go Programming Course // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ // // For more tutorials : https://learngoprogramming.com // In-person training : https://www.linkedin.com/in/inancgumus/ // Follow me on twitter: https://twitter.com/inancgumus package main ...
package main import ( _ "bytes" _ "encoding/json" "github.com/gorilla/mux" "log" "net/http" ) func RunMux() { r := mux.NewRouter() for url, h := range handler { r.HandleFunc(url, h) } r.PathPrefix("/schuhe/pic/").Handler(http.StripPrefix("/schuhe/pic/", http.FileServer(http.Dir("./data/schuhe/pic/")))) ...
package userstory type Session map[string]interface{}
package envoyconfig import ( "bytes" "context" "embed" "encoding/base64" "os" "path/filepath" "testing" "text/template" envoy_config_route_v3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/pomerium/pome...
package services import "errors" var ( ErrNameDuplicate = errors.New("forum name duplicate") ErrForumIdDuplicate = errors.New("forum_id duplicate") ErrInternal = errors.New("net worker error") )
//easyjson:json package easyjson1 import "time" type School struct { Name string `json:"name"` Addr string `json:"addr"` } //easyjson:json type Student struct { Id int `json:"id"` Name string `json:"s_name"` School School `json:"s_chool"` Birthday time.Time `json:"birthday"` }
package helper // FullTitle title for application func FullTitle(title string) string { basetitle := "Ruby on Rails Tutorial Sample App" if title == "" { return basetitle } return title + " | " + basetitle }