text
stringlengths
11
4.05M
package api import ( "crypto/rsa" "time" ) // OpenShiftCluster represents an OpenShift cluster type OpenShiftCluster struct { MissingFields ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` Location st...
package admin import ( "context" "tpay_backend/adminapi/internal/common" "tpay_backend/model" "tpay_backend/adminapi/internal/svc" "tpay_backend/adminapi/internal/types" "github.com/tal-tech/go-zero/core/logx" ) type DeleteUpstreamChannelLogic struct { logx.Logger ctx context.Context svcCtx *svc.Service...
package main import ( "encoding/json" "fmt" "log" ) type Envelope struct { Type string `json:"type"` Msg interface{} `json:"msg"` } type Sound struct { Description string `json:"description"` Authority string `json:"authority"` } type Cowbell struct { More bool `json:"more"` } func main() { s := E...
package input06 const Problem = `ZR5)FZS WCY)ZB3 NXV)8ZY CMN)CLW 4XG)8VX M8S)4F5 QWB)7WM JG4)VPL JG3)ZPC VKR)KF7 WH8)8RS CNS)D71 P3L)6SK CXM)HSV 9JX)D4R L25)4ZM C97)CNS 7R9)H6M XPT)QVX VMQ)9M2 8C4)8F8 MFN)WZF HP9)PBG L36)BH1 CHP)HP9 MJ3)783 48Y)BJM R4X)BPZ PSY)6FM HD5)FJX D8M)HLW 49J)KLD LZ4)7BZ 3LZ)TR5 NHB)WXK DMQ)Y2R...
package main import ( "cloud.google.com/go/storage" "cloud.google.com/go/vision/apiv1" "fmt" "golang.org/x/net/context" "io" "os" "testing" ) func _TestCanUploadToGoogleCloudStorage(t *testing.T) { client, err := storage.NewClient(context.Background()) if err != nil { // TODO: handle error. t.Errorf("%v"...
package timer import ( "time" ) type Interface interface { IncreaseLeftTime(key string, d time.Duration) // 增加定时器剩余时间 AddTimer(key string, d time.Duration, callback func()) // 添加定时器 OnDoTimer(key string) // 定时时间到了,处理定时器的callback HasTimer(key string) bool // 是否有定时器 CancelTimer(key string) bool // 撤消定时器 Reset() ...
// 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 services import ( "github.com/astaxie/beego" "github.com/goinggo/beego-mgo/utilities/mongo" "BeegoApi01/models" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) //** TYPES type ( // buoyConfiguration contains settings for running the buoy service. buoyConfig struct { Database string } ) //** PACKAGE V...
/* Copyright 2020 Cornelius Weig. 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...
package test import ( "encoding/json" "fmt" "testing" noSkipValidation "github.com/daverlo/generate/test/noSkipValidation_gen" "github.com/stretchr/testify/assert" ) func TestNoSkipValidation(t *testing.T) { // this just tests the name generation works correctly s := noSkipValidation.Simple{ Name: "name", ...
package main //nodemon --exec go run main.go --signal SIGTERM import ( "bytes" "encoding/json" "fmt" "html/template" "io/ioutil" "log" "net/http" "net/url" "os" "os/exec" "strconv" "strings" ) // type Page struct { Title string Body []byte } // type Tab struct { Nombre string Numer...
package main func main() { //命名规范 /* 1.允许使用数字,字母,下划线 不使用%@ 2.不允许使用关键字 3.不允许数字开头 4.区分大小写 5.见名知意 */ //驼峰命名法 /* 1.小驼峰:userName 2.大驼峰:UserName 3.下划线连接:user_name */ }
package utils var DefaultUserName = "navenduduari" var GogitArgs = []string{"--name=", "--help"} func IsCmdValid(argsMap map[string]string) bool { if len(argsMap) == 0 { return true } for _, validArg := range GogitArgs { for arg := range argsMap { if validArg == arg { return true } } } return f...
package sflow import ( "net" "github.com/google/gopacket" "github.com/google/gopacket/layers" "encoding/binary" ) //origin datagram info type Datagram struct { IPLength int SrcIP, DstIP net.IP SrcPort, DstPort uint16 } type Data struct { Type string Datagram Datagram DatagramVersion uint32 A...
// Copyright 2012, 2017 Dmitry Chestnykh. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package wots implements Winternitz-Lamport-Diffie one-time signature scheme. // // If the hash function is one-way and of sufficient length, the priv...
package main import ( "fmt" "os" "github.com/vmware-tanzu-labs/git-story/adapters" "github.com/vmware-tanzu-labs/git-story/usecases" "gopkg.in/salsita/go-pivotaltracker.v2/v5/pivotal" ) func newTracker() usecases.Tracker { apiToken := os.Getenv("TRACKER_API_TOKEN") client := pivotal.NewClient(apiToken) retur...
// Package importers helps with dynamic imports for templating package importers import ( "bytes" "fmt" "sort" "strings" "github.com/spf13/cast" "github.com/friendsofgo/errors" "github.com/volatiletech/strmangle" ) // Collection of imports for various templating purposes // Drivers add to any and all of thes...
package data import ( "database/sql" "../typefile" _ "github.com/lib/pq" ) //フォームから受け取ったタグデータを登録する func RegisterTag(tag typefile.TagData) { //データベースと接続する db, err := sql.Open("postgres", "user=trainer password=1111 dbname=imagebbs sslmode=disable") if err != nil { panic(err) } //タグデータを登録するSQL文をセットする stmt,...
// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
package controller import ( "fmt" "net/http" "time" "github.com/gin-gonic/gin" "gorm.io/gorm" "github.com/YusukeKishino/go-blog/model" ) type AdminPostsController struct { db *gorm.DB } func NewAdminPostsController(db *gorm.DB) *AdminPostsController { return &AdminPostsController{db: db} } func (c *AdminP...
package apis import ( "github.com/gin-gonic/gin" "log" "net/http" "strconv" "test/models" ) const pageSize = 10 func GetBlogs(c *gin.Context) { page := c.Request.FormValue("page") pages, err := strconv.Atoi(page) if err != nil{ log.Fatalln(err) } var b models.Blog blogs, err := b.GetBlogs(pages, pageSi...
package main import ( "time" "testing" "github.com/zhangmingkai4315/stream-topk/spacesaving" "github.com/zhangmingkai4315/stream-topk/stream" ) func makeFlow() (chan string) { config := map[string]int{ "a.com": 20, "b.com": 17, "c.com": 15, "d.com": 13, "e.com": 12, "f.com": 11, "g.com": 10, "h.c...
package main import "fmt" func main() { var x [5] int x[4] = 100 fmt.Println(x) }
package 排列组合问题 // 这题目就是要求: 有重复元素的数组的所有排列。 这个代码不求具体的,而是算有多少个不同的全排列。 func numTilePossibilities(tiles string) int { ans = 0 numTilePossibilitiesExec([]byte(tiles), 0) return ans - 1 // -1 是为了去除空的 } var ans int func numTilePossibilitiesExec(bytes []byte, index int) { /* if index == len(bytes){ ans++ } // 如果...
/* Copyright 2017 The Kubernetes Authors. SPDX-License-Identifier: Apache-2.0 */ package oimcsidriver import ( "context" "fmt" "os" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "github.com/pkg/errors" "github.com/intel/oim/pkg/log" "github.com/intel/oim/pkg/oim-common" "github.com/intel...
package main import "fmt" type Node struct { Value int Next *Node } var root = new(Node) func addNode(t *Node, v int) { if root == nil { t = &Node{v, nil} root = t return } for ; t.Next != nil; t = t.Next { //fmt.Println("") } t.Next = &Node{v, nil} } func contain(t *Node, v int) bool { if t ==...
package multi_terminal_login import ( "Open_IM/internal/push/content_struct" "Open_IM/internal/push/logic" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db" pbChat "Open_IM/pkg/proto/chat" "Open_IM/pkg/utils" ) func MultiTerminalLoginChecker(uid, token string, platformID int32) ...
package resources import ( "errors" "net/http" "github.com/manyminds/api2go" "gopkg.in/mgo.v2/bson" "themis/utils" "themis/models" "themis/database" ) // CommentResource for api2go routes. type CommentResource struct { CommentStorage *database.CommentStorage } func (c CommentResource) getFilterFromRequest(...
// Package globals provides global variables. package globals import "errors" // CalledInShell is true when mycomarkup is invoked as a program. var CalledInShell bool // TODO: get rid of these three ⤵. It requires quite an amount of work.︎ // HyphaExists holds function that checks if the hypha is present. By defaul...
package game_map import ( "fmt" "github.com/faiface/pixel" "github.com/faiface/pixel/pixelgl" "github.com/faiface/pixel/text" "github.com/steelx/go-rpg-cgm/combat" "github.com/steelx/go-rpg-cgm/gui" "math" "reflect" ) var rounds = []*ArenaRound{ {Name: "Round 1", Locked: false, Enemies: []combat.ActorDef{ ...
package server import ( "api/entities" "api/utils" "database/sql" "encoding/json" routing "github.com/qiangxue/fasthttp-routing" "github.com/valyala/fasthttp" ) // RegistrationHandler ... func (s *Server) RegistrationHandler() routing.Handler { return func(c *routing.Context) error { var user entities.User...
/*bcchain v2.0重大问题和修订方案1.1解决方案3 客户端测试正常数据*/ package main const ( LINUX_C4 = "tcp://192.168.80.150:46658" WINDOWS_C4 = "tcp://192.168.1.177:8080" ) //func main() { // a := make(chan bool) // clientCreator := proxy.NewRemoteClientCreator(LINUX_C4, "socket", true) // // cli, err := clientCreator.NewABCIClient() // i...
package store import "golang.org/x/oauth2" type Endpoint struct { AuthUrl string `json:"AuthUrl" envconfig:"AUTH_URL" required:"true"` TokenUrl string `json:"TokenUrl" envconfig:"TOKEN_URL" required:"true"` } type LinkedCloud struct { ID string `json:"ID"` Name string `json:"Name" envconfi...
package cookie import ( "encoding/base64" "encoding/gob" "encoding/json" "net/http" ) // Check if client has 'Do Not Track' enabled. func HasDnt(r *http.Request) bool { return r.Header.Get("Dnt") == "1" } // Check if user has opted out of having cookie set. func UserHasOptOut(r *http.Request) (b ...
package models import "github.com/jinzhu/gorm" type Goods struct { gorm.Model Title string Summary string Cover string Content string GoodsTypeId uint Sort uint Price string IsRecommend uint8 }
package main import ( "github.com/guoyk93/deployer/pkg/cmd" "github.com/guoyk93/deployer/pkg/tempfile" "log" ) func runBuildStage(opts Options) (err error) { log.Println("------------------------ 开始构建 ------------------------") defer log.Println("------------------------ 结束构建 ------------------------") // write...
package main import ( "bufio" "encoding/csv" "fmt" "github.com/weyllor/stocklab/stockdb" "log" "os" _ "time" ) func updateDb() { err := stockdb.UpdateStockDb() if err != nil { log.Fatal(err) } } func main() { fmt.Printf("Stock Lab.\n") updateDb() //testReadLastLines() //testCsvReadLastLines() //tes...
package leetcode type UnionFindSet struct { fathers []int } func MakeUnionFindSet(n int) *UnionFindSet { s := &UnionFindSet{fathers: make([]int, n)} for i := 0; i < n; i++ { s.fathers[i] = -1 } return s } func (s *UnionFindSet) SetFather(x int) { s.fathers[x] = x } func (s *UnionFindSet) Find(x int) int { ...
package main import ( "fmt" "os" "path/filepath" "io/ioutil" "log" "os/exec" ) func main() { log.Println("Server Started...") for ; ; { dicision := false files, err := ioutil.ReadDir("/mypath") if err != nil { log.Println(err) } fmt.Println(files) for _, value := range files { path := filepa...
package main import ( "fmt" "math" "strconv" "strings" ) var evens []int = []int{0, 2, 4, 6, 8} func main() { truncatablePrimes := []int{} for i := 11; len(truncatablePrimes) < 12; i += 2 { if !containsProblematicNumbers(i) { fmt.Println(i) if isTruncatablePrime(i) { truncatablePrimes = append(trun...
package main import ( "fmt" "github.com/rucuriousyet/divio" ) func main() { mux, _ := divio.NewMux("app", "", "") mux.AddRoute("apples/greenfroot", func(c *divio.Context) { flags, err := divio.ExpectFlags(divio.FlagGroup{ "f": &divio.Pair{"oranges", "sets the fruittype"}, "d": &divio.Pair{"poodle", "sets ...
package main import ( "fmt" "sort" ) // https://leetcode-cn.com/problems/maximum-gap/ // 164. 最大间距 | Maximum Gap //------------------------------------------------------------------------------ func maximumGap(nums []int) int { return maximumGap0(nums) } //--------------------------------------------------------...
package main import ( "os" "fmt" "log" "time" "bytes" "strconv" "net/http" "io/ioutil" "encoding/json" "github.com/gorilla/mux" ); var NODE_ID int; func __nodePrint(msg string) { fmt.Printf("Node %d: %s\n", NODE_ID, msg) } func handleRequests(PORT int) { fmt.Printf("listening for requests on port %d ......
package server import ( "fmt" "io" "net/http" "wsr-reader/wsr" ) func Run(addr string) error { http.HandleFunc("/", defaultPage) http.HandleFunc("/readCard", readCard) http.HandleFunc("/writeCard", writeCard) if err := http.ListenAndServe(addr, nil); err != nil { return err } return nil } func defaultP...
package authproxy import ( "context" "net/http" "strings" "github.com/janivihervas/authproxy/jwt" "golang.org/x/oauth2" "github.com/pkg/errors" ) const ( accessTokenCookieName = "access_token" authHeaderName = "Authorization" authHeaderPrefix = "Bearer" ) func (m *Middleware) getAccessTokenFr...
package main import "fmt" // 123 -> [(1 * 1) + (2 * 2) + (3 * 3)] + [(1*1*1) +(2*2*2) + (3*3*3)] func Nums(number int, numsChannel chan int) { for number != 0 { d := number % 10 numsChannel <- d number /= 10 } close(numsChannel) } func calcSquares(number int, sqrChannel chan int) { summ := 0 nChan := make...
// Implementação do comando echo. Versão 2. // arataca89@gmail.com // 20210412 package main import ( "fmt" "os" ) func main() { linha, espaco := "", "" for _, token := range os.Args[1:] { linha += espaco + token espaco = " " } fmt.Println(linha) } //////////////////////////////////...
package terraform import ( "bytes" "encoding/json" "fmt" "io" "net/url" "strconv" "strings" "sync" "sync/atomic" "time" "github.com/mattermost/mattermost-load-test/ltops" "github.com/mattermost/mattermost-load-test/sshtools" "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/crypto/ssh"...
/* Copyright © 2019 blacktop 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, merge, publish, distribute, sublicen...
package main import "lesson/channel/future" // 入口函数 func main() { future.Test1() }
package restclient import ( "encoding/json" "errors" "io" "log" "math/rand" "net" "net/http" "net/http/httptest" "net/url" "os" "path/filepath" "testing" "time" "github.com/kevinburke/rest/resterror" ) func TestNilClientNoPanic(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.Respo...
package utils // Abstract type Base struct { ID int64 `db:"id" json:"id"` CreatedTime Time `db:"created_time" json:"created_time"` UpdatedTime Time `db:"updated_time" json:"updated_time"` UpdatedSeq int64 `db:"updated_seq" json:"updated_seq"` // 乐观锁标记 Region string `db:"region" json:"region"`...
package main import ( "fmt" "os" "github.com/payfazz/go-errors-ext/errhandlerext" "github.com/payfazz/go-errors/errhandler" "github.com/payfazz/stdlog" ) func main() { defer errhandler.With(errhandlerext.LogAndExit) if len(os.Args) != 3 { showUsage() } switch os.Args[1] { case "server": runServer(os....
// Please, run go generate on root of this repository (github.com/devimteam/proto-utils) package _go import ( "time" devim_time "github.com/devimteam/proto-utils/src/main/go/time" "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/timestamp" "github.com/lib/pq" ) type Period struct { Start ...
package runner import ( "context" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestNewFakeRunner(t *testing.T) { f := NewFakeRunner(1) f2 := FakeRunner(1) assert.Equal(t, &f2, f) } func TestFakeRunner_WithContext(t *testing.T) { ctx, cancel := context.WithCanc...
// Source : https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/ // Author : Austin Vern Songer // Date : 2016-04-25 /********************************************************************************** * * Given a sorted array, remove the duplicates in place such that each element appear * only once ...
package main // All credits to: https://github.com/MovistarTV/tv_grab_es_movistartv/blob/master/tv_grab_es_movistartv.py#L610 import ( "net" "flag" "os" "fmt" "io" //"io/ioutil" "log" "time" "encoding/binary" //"encoding/xml" "github.com/ziutek/utils/netaddr" "github.co...
package mocks import ( "github.com/volatiletech/sqlboiler/v4/drivers" "github.com/volatiletech/sqlboiler/v4/importers" "github.com/volatiletech/strmangle" ) func init() { drivers.RegisterFromInit("mock", &MockDriver{}) } // MockDriver is a mock implementation of the bdb driver Interface type MockDriver struct{} ...
package main import ( "log" "os" ) func main() { file, err := os.OpenFile("test.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) if err != nil { log.Print(err) return } defer file.Close() log.SetOutput(file) log.Print("test") logger := log.New(file, "[mylogger]", log.LstdFlags) logger.Print("test") ...
package main import ( "github.com/social-network/subscan-plugin/example/system/http" "github.com/social-network/subscan-plugin/example/system/model" "github.com/social-network/subscan-plugin/example/system/service" "github.com/social-network/subscan-plugin/router" "github.com/social-network/subscan-plugin/storage...
package main import "fmt" // OPTIMIZE! This can be done in linear time. func maxAreaBruteForce(height []int) int { n := len(height) // assert(n > 1) max := 0 for i := 0; i < n-1; i++ { for j := i + 1; j < n; j++ { y := height[i] if height[j] < y { y = height[j] } a := y * (j - i) if a > max ...
package log import ( "github.com/ebar-go/ego/utils/strings" "github.com/stretchr/testify/assert" "testing" ) // TestNew 测试初始化 func TestNew(t *testing.T) { logger := New() assert.NotNil(t, logger) } func TestNewFileLogger(t *testing.T) { filePath := "/tmp/system.log" logger := NewFileLogger(filePath) assert.N...
package suites import ( "testing" "time" "github.com/go-rod/rod" "github.com/stretchr/testify/require" ) func (rs *RodSession) doFillLoginPageAndClick(t *testing.T, page *rod.Page, username, password string, keepMeLoggedIn bool) { usernameElement := rs.WaitElementLocatedByID(t, page, "username-textfield") pass...
package secrets import ( "fmt" "testing" "github.com/10gen/realm-cli/internal/cloud/realm" "github.com/10gen/realm-cli/internal/utils/test/assert" "github.com/10gen/realm-cli/internal/utils/test/mock" ) func TestSecretsDeleteInputsResolve(t *testing.T) { testLen := 7 secrets := make([]realm.Secret, testLen) ...
package fibweb_test import ( "encoding/json" "errors" "net/http" "net/http/httptest" "strconv" "testing" "github.com/uudashr/fibweb" "github.com/uudashr/fibweb/internal/mocks" ) func TestNumbers_validLimit(t *testing.T) { fibonacciService := new(mocks.FibonacciService) handler := fibweb.NewHTTPHandler(fibo...
package dp import "testing" func TestLCS(t *testing.T) { num1 := []int{1, 3, 5, 9, 10} num2 := []int{1, 3, 9, 10} println(longestCommonSubsequence1(num1, num2)) println(longestCommonSubsequence2(num1, num2)) println(longestCommonSubstring1("ABCD", "BCDA")) }
// Copyright 2017 The OpenSDS 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 agre...
package arch import ( "fmt" "io" "jugonz/chip8/src/gfx" "math/rand" "os" "time" ) /** * Datatype to describe the architecture of a Chip8 system. */ type Chip8 struct { // Core structural components. Opcode Opcode Memory [4096]uint8 Registers [16]uint8 IndexReg uint16 PC uint16 DelayT...
// matrix-websockets-proxy provides a websockets interface to a Matrix // homeserver implementing the REST API. // // It listens on a TCP port (localhost:8009 by default), and turns any // incoming connections into REST requests to the configured homeserver. // // It exposes only the one HTTP endpoint '/stream'. It is ...
package service import ( "github.com/godbus/dbus" "github.com/muka/go-bluetooth/bluez" "github.com/muka/go-bluetooth/bluez/profile/gatt" ) // NewGattDescriptor1 create a new GattDescriptor1 client func NewGattDescriptor1(config *GattDescriptor1Config, props *gatt.GattDescriptor1Properties) (*GattDescriptor1, error...
package stash import "testing" func TestGetSshUrl(t *testing.T) { clones := []Clone{ Clone{Name: "ssh", HREF: "ssh-url"}, Clone{Name: "http", HREF: "http-url"}, } links := Links{Clones: clones} repository := Repository{Links: links} sshURL := repository.SshUrl() if sshURL != "ssh-url" { t.Fatalf("Want ssh...
package tpi_data import ( _ "image" _ "image/jpeg" "reflect" "time" ) type Thali struct { Id int64 `json:"id"` Name string `json:"name"` Submitted time.Time `json:"submitted"` Target string `json:"target" schema:"target"` // 1-4 target customer profile Limited bool `json:"limi...
package vault import ( "io/ioutil" "log" "os" "github.com/dollarshaveclub/pvc" "github.com/pkg/errors" "github.com/dollarshaveclub/furan/lib/config" ) func getVaultClient(vaultConfig *config.Vaultconfig) (*pvc.SecretsClient, error) { var opts []pvc.SecretsClientOption if vaultConfig.Addr == "" { return ni...
package model // FieldType Information about the type of a field type FieldType struct { // Name The name of the field type Name string // VariableLength Whether the field is variable length VariableLength bool // FixedLength If fixed length field, otherwise -1 FixedLength int } // ConvBoolToBytes convert th...
package main import ( "context" "strings" "time" "github.com/yandex-cloud/examples/serverless/serverless_voximplant/scheme" "github.com/yandex-cloud/ydb-go-sdk" "github.com/yandex-cloud/ydb-go-sdk/table" ) func newSlots(ctx context.Context, req *slotsRequest) ([]*scheme.Entry, error) { query, params, err := n...
package main import ( "os" "fmt" "strconv" "math" ) func assert(id int, x bool) { if x == false { fmt.Printf("Assertion %v failed!\n", id) } } func min(x,y int) int { if x < y { return x } return y } func block(seq ElementSlice, i, n_blocks int) (ElementSlice, int) { n := len(seq) strid...
package cmd import ( "encoding/json" "fmt" "log" "strings" "time" calevents "github.com/connor-cahill/goCal/services" "github.com/spf13/cobra" ) //Event struct for displaying events type Event struct { Summary string `json:"summary"` Start EventTime `json:"start"` End EventTime `json:"end"` } //E...
package main import ( "bytes" "context" "crypto/tls" "encoding/base64" "encoding/json" "io" "net/http" "net/url" "regexp" "strings" "testing" "time" "github.com/gorilla/websocket" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/pomerium/pomerium/integration/flow...
package main import ( "bytes" "crypto/tls" "encoding/json" "encoding/xml" "html/template" "log" "net/http" "net/url" "os" "strconv" "strings" "github.com/codegangsta/negroni" "github.com/gorilla/mux" "github.com/gorilla/sessions" "github.com/unrolled/render" ) var rendering *render.Render var store = ...
package main import ( "context" "fmt" calendarRpc "github.com/Azimkhan/go-calendar-grpc/internal/calendar/delivery/grpc" "github.com/golang/protobuf/ptypes" "google.golang.org/grpc" "log" "time" ) func main() { cc, err := grpc.Dial("localhost:50051", grpc.WithInsecure()) if err != nil { log.Fatalf("could ...
package rpubsub import ( "context" "fmt" "github.com/pkg/errors" "github.com/batchcorp/plumber-schemas/build/go/protos/opts" "github.com/batchcorp/plumber-schemas/build/go/protos/records" "github.com/batchcorp/plumber/util" "github.com/batchcorp/plumber/validate" ) func (r *RedisPubsub) Write(ctx context.Co...
package cdb import ( "bufio" "bytes" "fmt" "io" "io/ioutil" "os" "testing" ) type rec struct { key string values []string } var records = []rec{ {"one", []string{"1"}}, {"two", []string{"2", "22"}}, {"three", []string{"3", "33", "333"}}, } var data []byte // set by init() func TestCdb(t *testing.T) ...
package issuer import ( "context" "crypto/rsa" "github.com/pkg/errors" "github.com/kumahq/kuma/pkg/core/resources/apis/system" "github.com/kumahq/kuma/pkg/core/resources/manager" "github.com/kumahq/kuma/pkg/core/resources/store" util_rsa "github.com/kumahq/kuma/pkg/util/rsa" ) type SigningKeyAccessor interfa...
package meta import ( mydb "FILE_STORE/db" "fmt" ) // 文件元信息结构 type FileMeta struct { // 文件唯一标志 FileSha1 string FileName string FileSize int64 Location string UploadAt string } var fileMetas map[string]FileMeta // 初始化 func init() { fileMetas = make(map[string]FileMeta) } // 修改元信息 func UpdateFileMeta(fmeta ...
// Copyright 2020 Clivern. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. package tower import ( "io/ioutil" "net/http" "github.com/clivern/walrus/core/driver" "github.com/clivern/walrus/core/model" "github.com/clivern/walrus/core/util" ...
package filter import ( "regexp" "strings" ) // // Filters used by the UEF // // TODO: - provide generic comparison from tables // TODO: - read comparison tables from files // try to transform strings into dc.language.iso fields // using ISO 639-1 (two character codes) // http://www.infoterm.info/standardization/...
package hamming import "errors" func Distance(a, b string) (int, error) { if len(a) != len(b) { return 0, errors.New("Length of two strings is different") } var distance int = 0 for index:=0; index<len(a); index++ { if a[index]!=b[index] { distance++ } } return di...
package main import ( "database/sql" "fmt" "net/http" "github.com/gin-gonic/gin" _ "github.com/lib/pq" uuid "github.com/satori/go.uuid" ) const ( host = "localhost" port = 5432 user = "migration-user" password = "password" dbname = "migration-test" ) type Beer struct { ID uuid.UUID `json...
package channel import ( "log" "websocket_chat/store" "websocket_chat/store/message" "github.com/gorilla/websocket" ) type Channel struct { Conn *websocket.Conn Send chan message.Message } func (this *Channel) Reader() { var ( msg message.Message ) for { err := this.Conn.ReadJSON(&msg) if err != ni...
package waktu // Month int. type Month int const ( // Januari = 1 Januari Month = 1 + iota // Februari = 2 Februari // Maret = 3 Maret // April = 4 April // Mei = 5 Mei // Juni = 6 Juni // Juli = 7 Juli // Agustus = 8 Agustus // September = 9 September // Oktober = 10 Oktober // Novembe...
// ANDY ZIMMELMAN 2019 package main // https://github.com/tensorflow/tensorflow/blob/master/tensorflow/go/example_inception_inference_test.go import ( "bytes" "log" tf "github.com/tensorflow/tensorflow/tensorflow/go" "github.com/tensorflow/tensorflow/tensorflow/go/op" ) func generateTensorFromImage(imageBuffer ...
package resources import ( "errors" "net/http" "github.com/manyminds/api2go" "gopkg.in/mgo.v2/bson" "themis/utils" "themis/models" "themis/database" ) // WorkItemTypeResource for api2go routes. type WorkItemTypeResource struct { WorkItemTypeStorage *database.WorkItemTypeStorage WorkItemStorage *database.Wo...
package config // based on https://cbonte.github.io/haproxy-dconv/1.6/configuration.html func NewBackend() *Backend { b := &Backend{ Values: make(map[string]Line, 0), Servers: make([]*Server, 0), } return b } type Backend struct { // name of the backend Name string // blindly parse all defaults for now ...
package controller import ( "database/sql" "encoding/json" "fmt" "io/ioutil" "log" "net/http" "projja_api/model" "strconv" "strings" "time" "github.com/go-martini/martini" "github.com/scylladb/go-set" ) func (c *Controller) GetTask(params martini.Params, w http.ResponseWriter) (int, string) { taskId, er...
package test import ( "strings" "testing" "time" //"github.com/gruntwork-io/terratest/modules/k8s" "github.com/gruntwork-io/terratest/modules/logger" "github.com/gruntwork-io/terratest/modules/random" "github.com/gruntwork-io/terratest/modules/terraform" test_structure "github.com/gruntwork-io/terratest/modul...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2020-08-10 16:41 # @File : log.go # @Description : # @Attention : */ package raft import "sync" // 存储的是日志信息 type LogInfo struct { } // 管理日志 type LogManager struct { Lock *sync.RWMutex Logs []LogInfo }
package postal import ( "io/ioutil" "os" ) type FileSystemInterface interface { Exists(string) bool Read(string) (string, error) } type FileSystem struct{} func NewFileSystem() *FileSystem { return &FileSystem{} } func (fs FileSystem) Exists(path string) bool { _, err := os.Stat(path) i...
// SPDX-License-Identifier: Apache-2.0 /* Sample Chaincode based on Demonstrated Scenario This code is based on code written by the Hyperledger Fabric community. Original code can be found here: https://github.com/hyperledger/fabric-samples/blob/release/chaincode/fabcar/fabcar.go */ package main /* Imports * 4...
package gochannels import ( "fmt" "time" ) var ch = make(chan string) // DoSomething init func DoSomething() { start := time.Now() go runB() go runA() fmt.Println(<-ch) fmt.Println(<-ch) elapsed := time.Since(start) fmt.Println("Procces took ", elapsed) } func runA() { time.Sleep(time.Second * 2) fmt.P...
package auth import ( "bytes" "log" "net/http" "net/url" json "github.com/cgonzalezg/babyblick-backend/deserialize" ) type AccesToken struct { Token string `json:"access_token"` Type string `json:"token_type"` ID string `json:"id_token"` } func Login(w http.ResponseWriter, r *http.Request) { // var js...