text
stringlengths
11
4.05M
package config /** * @author 16计算机 Moriaty * @version 1.0 * @copyright :Moriaty 版权所有 © 2020 * @date 2020/5/4 22:56 * @Description TODO * executor 配置 */ type ExecutorConfig struct { ClientConfig `ini:"client"` } type ClientConfig struct { Secret string `ini:"secret"` PhoneType string `ini:"phone_typ...
package main import "fmt" // START OMIT type Person struct { Name string Age uint } func (p Person) String() string { return fmt.Sprintf("%s (%d years)", p.Name, p.Age) } func main() { a := Person{"Arthur Dent", 42} fmt.Printf("with fmt.Printf(): %s\n", a) fmt.Println("with fmt.Println(): ", a) } // END OMI...
/* * Minio Cloud Storage, (C) 2016 Minio, 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 la...
// Verify referential templates include sync data package main import ( "context" "flag" "fmt" "io/fs" "log" "os" "path/filepath" "strings" constraintclient "github.com/open-policy-agent/frameworks/constraint/pkg/client" "github.com/open-policy-agent/frameworks/constraint/pkg/client/drivers/rego" "github....
package main import ( "fmt" "sort" ) func main() { nums := []int{-1, 0, 1, 2, -1, -4} sum := threeSum(nums) fmt.Println(len(sum)) } // TODO 未完成 func threeSum(nums []int) [][]int { if len(nums) <= 2 { return nil } sort.Ints(nums) result := make([][]int, 0, len(nums)) mp := make(map[string]int8) dupli...
package awssns import ( "context" "github.com/batchcorp/plumber/types" "github.com/batchcorp/plumber-schemas/build/go/protos/opts" "github.com/batchcorp/plumber-schemas/build/go/protos/records" ) func (a *AWSSNS) Relay(ctx context.Context, relayOpts *opts.RelayOptions, relayCh chan interface{}, errorCh chan<- *...
package space type Planet string func Age(seconds float64, planet Planet) (float64) { var years = seconds / (60*60*24*365.25) switch planet { case "Mercury": years /= 0.2408467 case "Venus": years /= 0.61519726 case "Mars": years /= 1.8808158 case "Jupiter": years /= 11.862615 case "Saturn": ...
package main import ( "log" "github.com/gorilla/mux" "github.com/nrkv/GoShare/api" "github.com/nrkv/GoShare/rand/sentence" "github.com/nrkv/GoShare/store" "os" ) // App stores config, db connection and all injected modules type App struct { Config *Config Router *mux.Router RandSente...
package broker type OffsetPagination struct { NextCursor string `json:"nextCursor,omitempty"` HasNext bool `json:"hasNext"` }
package rpc type RGBAInt uint64 // TODO: This is kind of related to themechanged... Oversee structure func (rgba RGBAInt) ToRGBInt() int32 { alpha := int32(rgba >> 24 & 0xFF) r, g, b := rgba.ToRGB() n := (1-alpha)*r + g + b return int32(n) } func (rgba RGBAInt) ToRGB() (int32, int32, int32) { red := rgba >> 16...
// This file was generated by counterfeiter package fake_nats_emitter import ( "sync" "github.com/cloudfoundry-incubator/route-emitter/routing_table" ) type FakeNATSEmitter struct { EmitStub func(messagesToEmit routing_table.MessagesToEmit) error emitMutex sync.RWMutex emitArgsForCall []struct { ...
package main import ( _ "embed" "fmt" "text/template" ) // START DATA OMIT var data = struct { TeamDescriptions map[string]string Employees []string }{ map[string]string{"DevX": "Amazing!"}, []string{"Carson", "Kari", "Tami", "Raul"}, } // END DATA OMIT const templateText = ` {{- "" -}} Team Descripti...
package mock import ( "github.com/docker/docker/client" ) type DockerImageClient interface { client.ImageAPIClient }
// Copyright 2017-2018 Hewlett Packard Enterprise Development LP // // 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 // // ...
package transaction import ( "bwa-startup/campaign" "bwa-startup/users" "time" "github.com/leekchan/accounting" ) type Transaction struct { ID int CampaignID int UserID int Amount int Status string Code string PaymentURL string CreatedAt time.Time UpdatedAt time.Time User users.Use...
package model type LearderBoard struct { LearderBoard []LeaderboardMember `json:"learder_board"` }
package entity import ( "encoding/json" "fmt" "github.com/fabric-lab/hyperledger-fabric-manager/server/pkg/store" "github.com/fabric-lab/hyperledger-fabric-manager/server/pkg/util" profileConfig "github.com/hyperledger/fabric/common/tools/configtxgen/localconfig" yaml "gopkg.in/yaml.v2" "io/ioutil" "path/filep...
package main import ( "bufio" "encoding/json" "flag" "fmt" "io/ioutil" "math/rand" "os" "os/exec" "path/filepath" "regexp" "runtime" "strings" "time" "github.com/tidusant/c3m-common/c3mcommon" "github.com/tidusant/c3m-common/inflect" "github.com/tidusant/c3m-common/log" "github.com/tidusant/c3m-commo...
package agent import ( "encoding/json" "os" "os/exec" "os/signal" "syscall" "time" "github.com/ehazlett/finca" "github.com/gomodule/redigo/redis" "github.com/sirupsen/logrus" ) func (a *Agent) Run() error { // TODO: subscribe to channel to stop when needed cmd, err := a.startLuxconsole() if err != nil { ...
// Copyright 2020 Kentaro Hibino. All rights reserved. // Use of this source code is governed by a MIT license // that can be found in the LICENSE file. package inspeq import ( "flag" "fmt" "math" "sort" "strings" "testing" "time" "github.com/go-redis/redis/v7" "github.com/google/go-cmp/cmp" "github.com/go...
package gzip import ( "io/ioutil" "os" "os/user" "path" "path/filepath" "runtime" "testing" . "github.com/anthonybishopric/gotcha" "github.com/square/p2/pkg/util" ) func testExtraction(t *testing.T, tarfile string, check func(error, string), ) { tarfile = path.Join("testdata", tarfile) // prefix with test...
package service import ( "encoding/json" "io/ioutil" "net/http" "strings" "github.com/go-chi/chi" "github.com/hoangbeatsb3/ttcourse/config" "github.com/hoangbeatsb3/ttcourse/model" // "github.com/hoangbeatsb3/ttcourse/repository" "../repository" "github.com/prometheus/common/log" ) var cfg = config.LoadEnv...
package logger import ( "go.uber.org/zap" ) type Logger interface { Debug(msg string) Info(msg string) } var logger *ZapLogger func init() { logger = NewLogger() } func GetLogger() *ZapLogger { return logger } type ZapLogger struct { logger *zap.Logger suger *zap.SugaredLogger } func NewLogger() *ZapLogg...
/* Copyright (c) 2017 GigaSpaces Technologies Ltd. All rights reserved Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable ...
package main import ( "context" "errors" "testing" "time" "github.com/brigadecore/brigade/sdk/v3" coreTesting "github.com/brigadecore/brigade/sdk/v3/testing" "github.com/brigadecore/brigade/v2/scheduler/internal/lib/queue" "github.com/stretchr/testify/require" ) func TestManageJobsCapacity(t *testing.T) { t...
package jawabundangan2 import ( "context" ) // Inport ... type Inport interface { Execute(ctx context.Context, req InportRequest) (*InportResponse, error) } // InportRequest ... type InportRequest struct { PesertaID string // Jawaban string // } // InportResponse ... type InportResponse struct { }
package main import ( "fmt" "github.com/ArtemBond13/hw2.1/pkg/card" "github.com/ArtemBond13/hw2.1/pkg/transfer" ) func main() { tinkoff := card.Service{ BankName: "Tinkoff", } //master := card.Card{ // Id: 0001, // Issuer: "MaaterCard", // Balance: 45234, // Currency: "", // Number: "3214 932...
package Layout import ( "testing" ) func TestAll(t *testing.T) { ctx := NewLayout() ctx.ReserveItemsCapacity(1024) root := NewLayItem(&ctx) root.SetSizeXY(1280, 720) root.SetContain(LayRow) master_list := NewLayItem(&ctx) root.Insert(&master_list) master_list.SetSizeXY(400, 0) master_list.SetBehave(LayVFill...
package main import "fmt" type Vertex struct { X, Y int } /* 表达式 new(T) 分配了一个零初始化的 T 值,并返回指向它的指针 */ func main() { v := new(Vertex) fmt.Println(v) v.X, v.Y = 11, 9 fmt.Println(v) v.X, v.Y = 10, 10 fmt.Println(*v) }
package models import "time" type User struct { ID string `gorm:"primary_key;unique_index,not_null" json:"id"` Username string `gorm:"type:varchar(255);NOT NULL;unique_index" json:"username"` Password string `gorm:"type:varchar(255);NOT NULL" json:"password"` Email string `gorm:"type:varchar(...
/* twitter@hector_gool */ package main import "fmt" func main() { const numero int = 11 for n := 1; n <= 10; n++ { fmt.Printf(" %v x %v = %v \n", numero, n, numero * n) } }
// Copyright 2020-2021 Buf Technologies, 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...
/* * 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 models type Order struct { Id int64 `json:"id"` Last_name string `json:"last_name"` First_name string `json:"first_name"` Email string `json:"email"` PhoneNumber string `json:"phone_number"` Address string `json:"address"` OrderItems []OrderItem `jso...
package main import ( "fmt" ) func main() { fmt.Println("Defer in Go") for i := 1; i <= 5; i++ { defer process(i) } } func process(id int) { fmt.Printf("Prosess %d\n", id) }
package main import ( "regexp" "fmt" "bytes" ) // https://gobyexample.com/regular-expressions func main() { // 簡単に含まれるか確認 match, _ := regexp.MatchString("p([a-z]+)ch", "peach") fmt.Println(match) // true // パターン作成 r, _ := regexp.Compile("p([a-z]+)ch") // パターンが含まれるか fmt.Println(r.MatchString("peach")) // ...
//参考https://github.com/caixw/lib.go/blob/master/validation/validator/regexp.go package validator import ( "testing" ) func TestIsEmail(t *testing.T) { if i := IsEmail("zshanjun@qq.com"); i != true { t.Error("fail") } if i := IsEmail("kdkkdk@dd"); i != false { t.Error("fail") } } func TestIsMobile(t *testing...
/* Copyright 2016 Stanislav Liberman Copyright (C) 2022 Talos, 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 ...
package controllers import ( "github.com/canghai908/zbxtable/models" ) // ItemController operations for Item type ItemController struct { BaseController } //ItemRes rep var ItemRes models.ItemList // URLMapping ... func (c *ItemController) URLMapping() { c.Mapping("GetItemByKey", c.GetItemByKey) c.Mapping("GetA...
package router import "net/http" type Http struct { Router string Handle func(w http.ResponseWriter, r *http.Request) error }
package main import ( "context" "database/sql" "log" "github.com/denisenkom/go-mssqldb" "github.com/gin-gonic/gin" "net/http" "gorm.io/gorm" ) var db *sql.DB var server = "localhost" var port = 1433 var user = "sa" var password = "123456789" var database = "restaurant" func main() { // Build connection stri...
package jawabundangan2 import ( "github.com/mirzaakhena/danarisan/domain/repository" "github.com/mirzaakhena/danarisan/domain/service" ) // Outport ... type Outport interface { repository.FindOnePesertaRepo repository.FindOneArisanRepo repository.SavePesertaRepo repository.SaveArisanRepo repository.SaveSlotRe...
package main import ( "bufio" "container/list" "fmt" "log" "os" "github.com/RyanCarrier/dijkstra" ) type player struct { lastTick int plType cellType hitPoints int attackPower int } type cell struct { x int y int player *player underlying cellType } type cellType byte ...
package leetcodego /* Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 */ func romanToInt(s string) int { var res int for i := len(s) - 1; i >= 0; i-- { ch := s[i] switch ch { case 'I': if res >= 5 { res += -1 ...
package middleware import ( "net/http" "net/http/httptest" "testing" "github.com/stretchr/testify/suite" ) type AuthorizationSuite struct { suite.Suite } func (s *AuthorizationSuite) Test() { middleware := NewAuthentication("0aac4e6a54c170b06e2bd3848d2b735e") client := &http.Client{ Transport: WithMiddlew...
package main // 注意: 此题其实是在求排列,而不是求组合。 // ----------------- 求取所有排列,之后求其长度 (此法超时) ----------------- var permutations [][]int func combinationSum4(nums []int, target int) int { permutations = make([][]int, 0) formPermutations(nums, []int{}, 0, target) return len(permutations) } func formPermutations(array []int, no...
package internationalization type Dollar float64
package models import ( "time" "github.com/manyminds/api2go/jsonapi" "gopkg.in/mgo.v2/bson" ) // LinkTypeName stores the common type name. const LinkTypeName = "workitemlinktypes" // LinkType is a type for a link. type LinkType struct { ID bson.ObjectId `bson:"_id,omitempty" json:"-"`...
package postgres import ( "context" "sync" "github.com/google/uuid" "github.com/jackc/pgx" "github.com/neuronlabs/errors" "github.com/neuronlabs/neuron-core/class" "github.com/neuronlabs/neuron-core/config" "github.com/neuronlabs/neuron-core/query" "github.com/neuronlabs/neuron-postgres/log" ) // compile ...
// Package pkgver implements parsing of xbps pkgver and pkgpatterns. // // The parsing follows: // pkgver ::= name [ ( version / pattern ) ] // name ::= [a-zA-Z0-9-]* // version ::= "-" [^-_]* "_" [^-]* // pattern ::= ( ">=" ">" / "<=" / "<" / "==" / "!=" ) .+ // // Note that a malformed version without "_" wil...
package main import ( "flag" "github.com/Sirupsen/logrus" "github.com/aws/aws-sdk-go/aws/session" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" "fmt" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/ecr" "k8s.io/client-go/tools/cach...
/* 创建者 : Luke 日期 : 2020年3月17日 联系方式: soekchl@163.com */ package networkLayer // 传送数据 type FormatData struct { Size int32 // 先所接受 size 大小 来决定 后续整体包大小 Id int32 Seq int32 Body []byte // json、portobuf } const ( max_buffer_size = 65536 // 最大buff长度 FirstReadSize = 4 // 首次读取32位 来判断后面部分数据长度 HeadSize ...
package core import ( "context" "time" "github.com/google/uuid" "github.com/pkg/errors" ) // RuntimeVariable are direktiv runtime variables that hold data, workflows performs getting and setting on these // data, RuntimeVariables also preserve state across multiple workflow runs. type RuntimeVariable struct { I...
package product var productDB []Product type MemoryRepo struct{} func (mr MemoryRepo) ProductInsert(merId int, m Product) error { productDB = append(productDB, m) return nil } func (mr MemoryRepo) FindProductByID(id int) (Product, error) { for _, m := range productDB { if m.ID == id { return m, nil } } ...
/* package handlers модуль players_turn обработчик для просчёта действий всех игроков за один ход */ package handlers import ( "encoding/json" "fmt" "math/rand" "net/http" "time" "github.com/AlexanderKorovaev/snake/server/core" ) // PlayersTurn получить координаты всех объектов func PlayersTurn(w http.Respons...
package customeError import ( "fmt" ) type MyError struct { Title string Message string } func (e MyError) Error() string { return fmt.Sprintf("%v: %v", e.Title, e.Message) } func main() { err := MyError{"Error Title 1", "Error Message 1"} fmt.Println(err) err = MyError{ Title: ...
package types // NewRandom constructs a Random func NewRandom(requestTxHash []byte, height int64, value string) Random { return Random{ RequestTxHash: requestTxHash, Height: height, Value: value, } }
package main import ( "context" "encoding/base64" "flag" "net/http" "os" "time" kit_log "github.com/go-kit/kit/log" "cloud.google.com/go/storage" "github.com/allegro/bigcache" "github.com/peterbourgon/ff/v3" "google.golang.org/api/option" weasel "github.com/revas-hq/weasel/pkg" weasel_inmem "github.com...
package syslog import ( "net" "testing" "time" ) func TestMessageNetSrc(t *testing.T) { tcpAddress, err := net.ResolveTCPAddr("tcp", "localhost:1234") if err != nil { t.Error("could not resolve TCP address") } m := &Message{time.Now(), tcpAddress, 0, 0, time.Now(), "", "", "", "", ""} if m.NetSrc() != "12...
package main import ( "bufio" "encoding/csv" "flag" "fmt" "io" "os" "path" "strings" "text/template" ) // generic type of any array of dictionaries a flat (csv) type GenericArrayMap []map[string]string // the initial input is a csv of header == key to row value per key row func main() { filePtr := flag.S...
// Copyright Amazon.com Inc. or its affiliates. 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. A copy of the // License is located at // // http://aws.amazon.com/apache2.0/ // // or in the "license" file ...
package main import ( "fmt" "log" "net/http" "os" ) // var port = flag.Int("p", 80, "port") func main() { // flag.Parse() port := 80 dir, err := os.Getwd() if err != nil { log.Panicln(err) } fmt.Printf("http://127.0.0.1:%d/index.html \nDir: %s\n", port, dir) err = http.ListenAndServe(fmt.Sprintf(":%d...
package main import ( "fmt" ) func main() { f(false) f(true) } func f(p bool) { defer func() { fmt.Println("defer started") if err := recover(); err != nil { fmt.Println("panic interrupted:", err) } fmt.Println("defer ended") }() if p { panic("panic occurred") } }
package finident import "strings" var validCFI = map[string][]string{ // Equities "ES": []string{"VNRE", "TU", "OPF", "BRNM"}, "EP": []string{"VNRE", "RETGACN", "FCPQANU", "BRNM"}, "EC": []string{"VNRE", "TU", "OPF", "BRNM"}, "EF": []string{"VNRE", "RETGACN", "FCPQANU", "BRNM"}, "EL": []string{"VNRE", "TU", "OP...
//author xinbing //time 2018/8/31 14:15 //简单的内存cache,可以支持过期时间设置 package caches import ( "fmt" "time" "sync" ) // 读锁不阻塞读锁 // 读锁阻塞写锁,直到所以读锁都释放 // 写锁阻塞读\写锁,直到写锁都释放 //待优化 type SimpleCache struct { rwMutex *sync.RWMutex //读写锁 cache map[string]*element //存放的map //strategy SimpleStrategy //过期策略 globalExpire int64 //全...
package streamdal import ( "bufio" "encoding/json" "fmt" "io" "net/http" "os" "strings" "syscall" "github.com/batchcorp/plumber/config" "github.com/pkg/errors" "golang.org/x/crypto/ssh/terminal" ) // AuthResponse is used to unmarshal the JSON results of a login API call type AuthResponse struct { Accoun...
package mongodb import "gopkg.in/mgo.v2" type Database struct { s *mgo.Session name string session *mgo.Database } func (db *Database) Connect() { db.s = service.Session() session := *db.s.DB(db.name) db.session = &session } func newDBSession(name string) *Database { var db = Database{ name: na...
package requests import "github.com/go-playground/validator" type Request struct { } // use a single instance of Validate, it caches struct info var validate *validator.Validate
// DO NOT EDIT. This file was generated by "github.com/frk/gosql". package testdata import ( "github.com/frk/gosql" ) func (q *SelectCountQuery) Exec(c gosql.Conn) error { const queryString = `SELECT COUNT(*) FROM "test_user" AS u ` // ` row := c.QueryRow(queryString) return row.Scan(&q.Count) }
/* * @File: models.user.go * @Description: Defines User model * @Author: Nguyen Truong Duong (seedotech@gmail.com) */ package models import ( "errors" "../common" "gopkg.in/mgo.v2/bson" ) // User information type User struct { ID bson.ObjectId `bson:"_id" json:"id" example:"5bbdadf782eb...
package base type WebSocketResponseBase struct { Status string `json:"status"` Channel string `json:"ch"` Timestamp int64 `json:"ts"` }
// 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 volume import ( "encoding/json" "errors" "fmt" "strconv" "time" "github.com/Huawei/eSDK_K8S_Plugin/src/storage/oceanstor/client" "github.com/Huawei/eSDK_K8S_Plugin/src/storage/oceanstor/smartx" "github.com/Huawei/eSDK_K8S_Plugin/src/utils" "github.com/Huawei/eSDK_K8S_Plugin/src/utils/log" "github.co...
// Copyright 2020 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 "fmt" func main() { rf := firstFunk() fmt.Println(rf()) fmt.Printf("%T\n", rf) } func firstFunk() func() string { return func() string { return "This is a nested func." } }
package main import ( "github.com/aws/aws-sdk-go/service/autoscaling" "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/elb" "github.com/aws/aws-sdk-go/service/cloudformation" "github.com/aws/aws-sdk-go/service/iam" "github.com/aws/aws-sdk-go/service/efs" "github.com/aws/aws-sdk-go/serv...
package sdl type SDL_GestureID int64
package users import "github.com/jinzhu/gorm" type Manager struct { *gorm.DB `inject:""` } func (m *Manager) FindOrCreateUser(userAuthID string) (*User, error) { user := &User{} m.Where("auth_id = ?", userAuthID).First(user) // no user in DB if user.AuthID == "" { // create user user.AuthID = userAuthID ...
/* Copyright IBM Corporation 2020 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 tempconv func CToF(c Celsius) Fehrenheit { return Fehrenheit(c*9/5 + 32) } func FToC(f Fehrenheit) Celsius { return Celsius((f - 32) * 5 / 9) }
package main import ( "fmt" "math/rand" "time" ) func main() { r := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(100000000) fmt.Println(r) }
package main import ( "reflect" "testing" ) func TestMakeInt(t *testing.T) { want := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} got := make([]int, 0) s := MakeInt(1, 10) for { v, ok := <-s if !ok { break } got = append(got, v) } if !reflect.DeepEqual(got, want) { t.Errorf("MakeInt(1, 10) = %v, want: %v...
package clip import ( "bytes" "os/exec" ) func Primary() string { return Xclip("primary") } func Xclip(selection string) string { buf := new(bytes.Buffer) cmd := exec.Command("xclip", "-o", "-selection", selection) cmd.Stdout = buf cmd.Run() return buf.String() }
package raindrops import "strconv" const testVersion = 2 // Convert converts input number to string like 3, Pling, 5, Plang, 7, Plong func Convert(num int) string { s := "" if num%3 == 0 { s += "Pling" } if num%5 == 0 { s += "Plang" } if num%7 == 0 { s += "Plong" } if s == "" { s = strconv.Itoa(num) ...
package controller import ( "github.com/gin-gonic/gin" "net/http" "sort" "crypto/sha1" "strings" "fmt" "io" "regexp" ) func verifyWxSignature(signature,url,nonce string) bool{ flysnowRegexp:=regexp.MustCompile(`xtamp=(\d+)`) fmt.Printf("我是url%q\n",url) params := flysnowRegexp.FindStringSubmatch(url) arr ...
package main import ( "buildings/httpd/handler" "buildings/platform/model" "fmt" "github.com/gin-gonic/gin" ) func main() { //init repo repo := model.New() r := gin.Default() // Recovery middleware recovers from any panics and writes a 500 if there was one. r.Use(gin.Recovery()) r.GET("/building", handler...
// Package failured implements the Adaptive Accrual Failure Detector /* This package implements [A New Adaptive Accrual Failure Detector for Dependable Distributed Systems](https://dl.acm.org/citation.cfm?id=1244129) To use the failure detector, you need a heartbeat loop that will call RegisterHeartbeat() at regular ...
package main import ( "bytes" "compress/gzip" "encoding/json" "io/ioutil" "log" "net/http" "time" ) type Test struct { Id int64 Name string } func init() { log.SetFlags(log.LstdFlags | log.Lshortfile) } func main() { mux := http.NewServeMux() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Re...
package main import ( "io/ioutil" "log" "net/http" ) func main() { //오류체크 생략 resp, _ := http.Get("http://localhost:18888") defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) log.Println(string(body)) //상태정보 log.Println("Status:", resp.Status) // "200 OK" //상태코드 log.Println("Status:", resp.Statu...
// +build openbsd package protector import ( "log" "golang.org/x/sys/unix" ) // Source https://github.com/junegunn/fzf/blob/a1bcdc225e1c9b890214fcea3d19d85226fc552a/src/protector/protector_openbsd.go // Protect calls OS specific protections like pledge on OpenBSD func Protect(writeOutDirPath string) { mustInclu...
package main import ( "bytes" "crypto/tls" "encoding/json" "flag" "io" "log" "net/http" "net/http/cookiejar" "os" ) const ( API_BASE = "https://support.fortinet.com" API_PATH = "/RegistrationAPI/FCWS_RegistrationService.svc/REST/REST_GetAssets" ) var ( url = os.Getenv("FCURL") tkn = os.Getenv("FCT...
/* Copyright 2021 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 main import ( "fmt" "github.com/dutchcoders/goftp" "github.com/kbinani/screenshot" "image/png" "net" "os" "os/signal" "syscall" "time" ) func main() { done := make(chan os.Signal, 1) signal.Notify(done, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) snipping() //不退出 <-done } func snipping() ...
package net import "testing" func TestValidateMAC(t *testing.T) { type args struct { mac string } tests := []struct { name string args args want bool }{ {"Empty", args{""}, false}, {"Zero", args{"00:00:00:00:00:00"}, false}, {"Broadcast", args{"FF:FF:FF:FF:FF:FF"}, false}, {"IPv4 multicast", args{...
// 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 in writing...
package main import ( "fmt" "github.com/coreswitch/cmd" "log" "strings" ) type LagoCh struct { Name string DstAddr string DstPort string Protocol string Create bool Change bool } var Channels = make(map[string]*LagoCh) func GetChannel(name string) *LagoCh { _, ok := Channels[name] if !ok { C...
package extract_test import ( "reflect" "testing" ) import ( "github.com/pjdufour/go-gypsy/yaml" "github.com/pjdufour/go-extract/extract" ) var filename = "test.yml" var tests = []struct { keyChain string fallback interface{} expectedType string expectedValue interface{} }{ {"view.zoom", 3, "int...
package command import ( "io" "os" ) var stdout, stderr io.Writer = os.Stdout, os.Stderr
package rd_test import ( "bytes" "io/ioutil" "net/http" "testing" "github.com/nenad/rd" "github.com/stretchr/testify/assert" ) const defaultClientID = "X245A4XAIBGVM" type TestRoundTripFunc func(req *http.Request) *http.Response func (rt TestRoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error...
package dbr import ( dbr "github.com/gocraft/dbr/opentracing" bgo "github.com/pickjunk/bgo" log "github.com/sirupsen/logrus" ) // Logger for dbr type Logger struct { *bgo.Logger *dbr.EventReceiver } // NewLogger for dbr func NewLogger() *Logger { return &Logger{ bgo.Log, &dbr.EventReceive...