text
stringlengths
11
4.05M
package navmap import ( "bytes" "compress/gzip" "database/sql" "encoding/binary" "fmt" "image" "image/color" "image/png" "io" "time" _ "github.com/mattn/go-sqlite3" "github.com/simonswine/rocklet/pkg/apis/vacuum/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) type Cleaning struct { BeginTime...
package main import ( "net" "log" "google.golang.org/grpc" "golang.org/x/net/context" pb "github.com/DemoLiang/demo/grpc/pb" "google.golang.org/grpc/reflection" ) const ( port = ":50051" ) type server struct { } func (s *server)SayHello(ctx context.Context,in *pb.HelloRequest)(*pb.HelloReply,error){ return ...
package main import ( "fmt" "os" ) func f1() { fileObj, err := os.Open("./main.go") if err != nil { fmt.Printf("open file failed ,err :%v", err) } fmt.Println(fileObj) } func main() { f1() }
package sysdnotify import ( "fmt" "net" ) var socket *net.UnixAddr // IsEnabled tells if systemd notify socket has been detected or not. func IsEnabled() bool { return socket != nil } // Ready sends systemd notify READY=1 func Ready() error { return Send("READY=1") } // Reloading sends systemd notify RELOADING...
package main import ( "io/ioutil" "net/http" "os" "log" "bufio" "bytes" "strings" "flag" "time" "sync" "github.com/fatih/color" ) func main () { color.Cyan(` ___________ ____ _______ __ / ____/ ___// __ \/ ____/ |/ / / / \__ \/ /_/ / /_ | / / /___ ___/ / _, _/ __/ / | \____//____/_/ |_/_/ ...
package huffman_tree import "testing" func TestCreateHuffmanTree(t *testing.T) { arr := []int{13, 7, 8, 3, 29, 6, 1} t.Log(CreateHuffmanTree(arr).String()) }
package app import ( "encoding/gob" "html/template" "log" "net/http" "github.com/gorilla/handlers" "github.com/gorilla/sessions" "github.com/huin/httpauth/prometheusutil" "github.com/huin/httpauth/userlist" "github.com/juju/ratelimit" "github.com/prometheus/client_golang/prometheus" ) const sessionName = "...
// Copyright(c),Shanghai Connext Information Technology Co., Ltd.,All Rights Resevered. /* Time: 2019/6/20 Author: trump.liu File: orm_pagination.go Describe: pagination for orm use */ package pagination import "github.com/connext-cs/pub/response" import "errors" // get orm limit and offset // // Input // pag...
package cmd import ( "encoding/json" "fmt" "os" "text/template" "strings" "github.com/coreos/clair/api/v1" "github.com/coreos/clair/utils/types" "github.com/fatih/color" "github.com/ContinuousSecurityTooling/clairctl/clair" "github.com/ContinuousSecurityTooling/clairctl/config" "github.com/ContinuousSecur...
//Copyright (C) 2020 Daniel Bokser. See LICENSE file for license package main import ( "bytes" "image/gif" "io/ioutil" "math/rand" "os" "strconv" "testing" "twitter" ) func test_assert_eq(expected, actual interface{}, msg string, t *testing.T) { if actual != expected { switch ex := expected.(type) { ca...
package xtractr import ( "archive/zip" "fmt" "os" "path/filepath" "strings" ) /* How to extract a ZIP file. */ // ExtractZIP extracts a zip file.. to a destination. Simple enough. func ExtractZIP(x *XFile) (int64, []string, error) { zipReader, err := zip.OpenReader(x.FilePath) if err != nil { return 0, nil,...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2020-08-10 16:43 # @File : commuciate.go # @Description : 用于交流 # @Attention : */ package raft type Entry struct { }
package sessions import ( "crypto/rand" "encoding/base64" "encoding/json" "fmt" "io/ioutil" "net/http" "os" "strings" "github.com/KyleWS/blog-api/api-server/logging" cache "github.com/patrickmn/go-cache" "github.com/sirupsen/logrus" "golang.org/x/oauth2" ) const ( headerContentType = "Content-Type" hea...
package main // Here you can define the type of the element to be sorted. type Element int32 type ElementSlice []int32 type PElement Pair type PElementSlice []Pair
package main import ( "fmt" "io/ioutil" "log" "sort" "strconv" "strings" ) func parseTime(line string) int { words := strings.Split(line, " ") time := strings.Split(words[1], "]")[0] minutes, err := strconv.Atoi(strings.Split(time, ":")[1]) if err != nil { log.Fatal(err) } return minutes } func getGuar...
package aggregate import ( "testing" "github.com/XiaoMi/pegasus-go-client/idl/base" "github.com/stretchr/testify/assert" ) func TestPerfClientGetNodeStats(t *testing.T) { pclient := NewPerfClient([]string{"127.0.0.1:34601"}) nodes := pclient.GetNodeStats("@") assert.Greater(t, len(nodes), 0) assert.Greater(t,...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //213. House Robber II //Note: This is an extension of House Robber. //After robbing those houses on that street, the thief has found himself a new pla...
package Problem0283 func moveZeroes(nums []int) { l := len(nums) i, j := 0, 0 for j < l { if nums[j] != 0 { nums[i] = nums[j] i++ } j++ } // 此时,i 以前的位置上,保存了nums中所有的非零数 // 所以,只要把 nums[i:] 都置零,即可 for i < l { nums[i] = 0 i++ } }
package colr import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00800103 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:colr.008.001.03 Document"` Message *CollateralProposalResponseV03 `xml:"CollPrpslRspn"` } func (d *Document008...
package configs import ( "github.com/spf13/cobra" "github.com/spf13/viper" "go.uber.org/zap" "ukor/internal/utils" ) var props *properties = new(properties) type properties struct { Server struct { Port int32 PublicKey string PrivateKey string } Telegram struct { BaseURL string APIKey...
package sv // ==== Message ==== // CommitMessageConfig config a commit message. type CommitMessageConfig struct { Types []string `yaml:"types,flow"` HeaderSelector string `yaml:"header-selector"` Scope CommitMessageScopeConfig ...
package Solution func Solution(A []int) []bool { n := len(A) if n == 1 { if A[0] == 0 { return []bool{true} } else { return []bool{false} } } ans, v := make([]bool, n), 0 for i := 0; i < n; i++ { v = (2*v + A[i]) % 5 if v == 0 { ans[i] = true } else { ans[i] = false } } return ans }
package main import ( "fmt" ) func canJump(nums []int) bool { // 不断更新最大距离max_r max_r := 0 for i := 0; i <= max_r; i++ { if (nums[i] + i) >= max_r { max_r = nums[i] + i } if max_r >= len(nums)-1 { return true } } return false } func main() { nums := []int{2, 5, 0, 0} fmt.Println(canJump(nums)) ...
package define const Example = ""
package rpcd import ( "github.com/Cloud-Foundations/Dominator/lib/errors" "github.com/Cloud-Foundations/Dominator/lib/srpc" "github.com/Cloud-Foundations/Dominator/proto/hypervisor" ) func (t *srpcType) AddVmVolumes(conn *srpc.Conn, request hypervisor.AddVmVolumesRequest, reply *hypervisor.AddVmVolumesResponse) ...
package main import "fmt" // 结构体的继承 // 用户结构体 type Animal struct { name string } func (a Animal) run() { fmt.Printf("%v 在运动 \n", a.name) } // 子结构体 type Dog struct { age int // 通过结构体嵌套,完成继承 Animal } func (dog Dog) wang() { fmt.Printf("%v 在汪汪汪 \n", dog.name) } func main() { var dog = Dog{ age: 10, Animal: An...
package chain import ( "fmt" "os" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance" "github.com/iotaledger/wasp/packages/coretypes" "github.com/iotaledger/wasp/packages/kv" "github.com/iotaledger/wasp/packages/kv/codec" "github.com/iotaledger/wasp/packages/kv/dict" "github.com/iotaledger...
package main import ( "bytes" "fmt" "io/ioutil" "net/http" "net/http/httptest" "strings" "testing" ) func TestSayHiHandler(t *testing.T){ tt := []struct{ method string endpoint string expected string }{ {method: "GET", endpoint: "localhost:8080/", expected: "Hi, im glad you call\n" }, {method: "POS...
package test import ( "bytes" "encoding/json" "fmt" "reflect" "runtime/debug" "strings" "testing" ) func fail(t *testing.T, msg string) { debug.PrintStack() t.Fatalf(msg) } func AssertTrue(t *testing.T, value bool) { if value == true { return } fail(t, fmt.Sprintf("expected true got %v", value)) } f...
package ast import ( "github.com/graphql-go/graphql/language/kinds" ) // Name implements Node type Name struct { Kind string Loc *Location Value string } func NewName(node *Name) *Name { if node == nil { node = &Name{} } node.Kind = kinds.Name return node } func (node *Name) GetKind() string { return ...
package goi // Types of compression const ( NOCPRSN = iota SHOCO SHOCODICT ) // Config provides a configuration with default settings var Config = NewConfig() // ObjectInternConfig holds a configuration to use when creating a new ObjectIntern. // Currently, Index and MaxIndexSize don't do anything. type ObjectInt...
package cmd import ( "fmt" "os" "path/filepath" homedir "github.com/mitchellh/go-homedir" "github.com/spf13/cobra" "github.com/spf13/viper" ) var ( authKey string cfgFile string email string ) func Execute() { cobra.OnInitialize(initConfig) err := newCmdRoot().Execute() if err != nil { fmt.Println(...
package utilpq import ( //"fmt" "github.com/priya23/finalpq" "github.com/priya23/finalpq/implementheap" ) func CreateHeap() *implementheap.PriorityQueue { v1 := implementheap.CreateHeap() return v1 } func CreateNewNode(val int, prior int) *implementheap.Item { k := implementheap.CreateNew(val, prior) return k...
package main import ( "fmt" ) func out(arr [4]int) { for i := range arr { fmt.Printf("%d ", arr[i]) } } func main() { var size = 4 // 1 var arr [4]int // 2 left := 0 // 3 right := size - 1 // 4 for i := range arr { // 5 arr[i] = size - i // 6 } for left < right { // 7 for ...
package leetcode import ( "reflect" "testing" ) func TestIntersect(t *testing.T) { tests := []struct { nums1 []int nums2 []int results []int }{ { nums1: []int{1, 2, 2, 1}, nums2: []int{2, 2}, results: []int{2, 2}, }, { nums1: []int{4, 9, 5}, nums2: []int{9, 4, 9, 8, 4}, r...
package main import ( "github.com/google/go-cmp/cmp" "testing" ) func TestDataToSliceString(t *testing.T) { testData := "a b c d f e" testDataExpectedResult := []string{"a", "b", "c", "d", "f", "e"} data := DataToSliceString(testData) if cmp.Equal(data, testDataExpectedResult) != true { t.Log(data) t.Log(te...
package waddrmgr import ( "fmt" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/txscript" ) // TapscriptType is a special type denoting the different variants of // tapscripts. type TapscriptType uint8 const ( // TapscriptTypeFullTree is the type of tapscript that knows its full // tree with all ...
// Copyright 2021 Clivern. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. package service import ( "fmt" "os" "os/exec" "strings" ) // FuzzyFinder type type FuzzyFinder struct{} // Available validates if fzf installed func (f *FuzzyFinder...
// Package server contains core functionality for our cache servers; storing & retrieving files etc. package server import ( "bytes" "fmt" "io/ioutil" "os" "path" "path/filepath" "sort" "strings" "sync" "sync/atomic" "time" "github.com/djherbis/atime" "github.com/dustin/go-humanize" "github.com/streamra...
package main import ( "fmt" "github.com/hwaf/hwaf/hlib" ) func (r *Renderer) render_wscript() error { var err error enc := hlib.NewHscriptPyEncoder(r.w) if enc == nil { return fmt.Errorf("got invalid hscript-py encoder") } err = enc.Encode(&r.pkg) if err != nil { return err } return err } // EOF
// Copyright 2021 BoCloud // // 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 wri...
package main import ( "fmt" ) func updatesChoices() { fmt.Print("Enter an int, based on the above options.") var uChoice int fmt.Scan(&uChoice) }
// +build integration package integration import ( "github.com/trivago/tgo/ttesting" "os" "testing" "time" ) const ( testFileConsumerConfig = "test_file_consumer.conf" testFileConsumerWhite = "test_file_consumer_white.conf" testFileConsumerBlack = "test_file_consumer_black.conf" testFileConsum...
// Package hashutil provides NON-CRYPTOGRAPHIC utility functions for hashing package hashutil import ( "testing" "github.com/stretchr/testify/assert" ) func TestHash(t *testing.T) { t.Parallel() tests := []struct { name string v interface{} want uint64 wantErr bool }{ {"string", "string", ...
package saturn import "fmt" type Page struct { Paths []*PathComponent Content *PageContent Title string } type PathComponent struct { Name string Title string URL string } func NewPathComponent(name, title, url string) *PathComponent { return &PathComponent{Name: name, Title: title, URL: url} } func ...
package router import ( "github.com/labstack/echo/v4" "github.com/tzilist/m-service/pkg/controllers" ) // CreateRoutes creates the server routes func CreateRoutes(server *echo.Echo) { server.GET("/:channel/messages", controllers.GetChannelMessages) server.POST("/:channel/messages", controllers.PostChannelMessage)...
package mfs type Flags struct { Read bool Write bool Sync bool }
// 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 cache import ( "container/list" "fmt" "math" "strconv" ) const AddressSize = 32 //cache address line length in bits type CacheCmd struct { Type int Address string } type CacheRequest struct { Offset uint64 SetNumber uint64 Tag uint64 } type Cache struct { Options *Options ...
package cmd import ( "fmt" "github.com/integr8ly/delorean/pkg/types" "io/ioutil" "os" "path" "strings" "testing" "github.com/ghodss/yaml" olmapiv1alpha1 "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plu...
package gunittesting import ( "errors" "gunittesting/domain" "gunittesting/interfaces" ) type PersistentStore struct { store interfaces.KeyValueStore serialiser interfaces.Serialiser } func NewPersistentStore(store interfaces.KeyValueStore, serialiser interfaces.Serialiser) *PersistentStore { return &Pers...
package routers import ( "encoding/json" "net/http" "time" "github.com/IsaiasMorochi/twitter-clone-backend/dao" "github.com/IsaiasMorochi/twitter-clone-backend/lib" "github.com/IsaiasMorochi/twitter-clone-backend/models" ) func Login(w http.ResponseWriter, r *http.Request) { w.Header().Add("Content-Type", "a...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //504. Base 7 //Given an integer, return its base 7 string representation. //Example 1: //Input: 100 //Output: "202" //Example 2: //Input: -7 //Output:...
package grbl import ( "bufio" "strings" "testing" "github.com/stretchr/testify/assert" ) func TestScanInput(t *testing.T) { const input = ` code ; command line ; with middle comment and one (with center) comment and a (broken ; one) yet another ( broken one ` s := bufio.NewScanner(strings.NewReader(input)) ...
package congestion import ( "math" "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/protocol" ) const numConnections uint32 = 2 const nConnectionBeta float32 = (float32(numConnections) - 1 + beta) / float32(numConnections) cons...
package lingua import ( "encoding/json" "fmt" "io/ioutil" "net/http" ) const ( ApiUrl = "https://lingua-robot.p.rapidapi.com/language/v1/entries/en" ApiHost = "lingua-robot.p.rapidapi.com" ) type HTTPClient interface { Do(req *http.Request) (*http.Response, error) } type Lingua struct { HttpClient HTTPClie...
package main import ( "log" "github.com/Kucoin/kucoin-go-sdk" ) func main() { //s := kucoin.NewApiServiceFromEnv() s := kucoin.NewApiService( kucoin.ApiKeyOption("key"), kucoin.ApiSecretOption("secret"), kucoin.ApiPassPhraseOption("passphrase"), ) serverTime(s) accounts(s) orders(s) publicWebsocket(s)...
// Copyright 2016 NetApp, Inc. All Rights Reserved. package ontap import ( "fmt" "os/exec" "strconv" log "github.com/Sirupsen/logrus" dvp "github.com/netapp/netappdvp/storage_drivers" "github.com/netapp/netappdvp/apis/ontap" "github.com/netapp/trident/config" "github.com/netapp/trident/storage" sa "github....
package handlers import ( "fmt" "os" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" ) // AWS sesssion wrapper type AwsClient struct { session *session.Session } ...
package main import ( "fmt" "os" "github.com/slcjordan/reading" ) func main() { var days int fmt.Print("How many days to read d&c? ") _, err := fmt.Fscanf(os.Stdin, "%d", &days) if err != nil { fmt.Println(err) return } var idx int fmt.Print("How would you like that broken down [(1) Chapter (2) Verse]?...
package main import ( "fmt" "sync" ) var raceCondition int func main() { wg := sync.WaitGroup{} wg.Add(100) for i := 0; i < 100; i++ { go sum10(&wg) } wg.Wait() fmt.Println(raceCondition) } func sum10(wg *sync.WaitGroup) { for i := 0; i < 10; i++ { value := raceCondition value++ raceCondition = val...
// 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 admincli import ( "log" "net/http" ) type AssignWorkplaces struct { } func (r AssignWorkplaces) Execute() { req, _ := http.NewRequest( "GET", config.Host+"/sitomat", nil) req.SetBasicAuth(config.AdminUsername, config.AdminPassword) res, err := client.Do(req) if err != nil { log.Fatal(err) } ...
package main import "fmt" func main(){ fmt.Println("Program to demonstrate logical operations in Go:") var ( num1 = true num2 = false ) fmt.Println(num1, "||", num2, ":", num1 || num2) fmt.Println(num1, "&&", num2, ":", num1 && num2) fmt.Println("!(", num1, "&&", num2, ") :", !(num1 && num2)) }
package viewmodel // StandLocator struct type StandLocator struct { Title string Active string Alert string AlertMessage string AlertDanger string AlertSuccess string } // StandCoordinate struct type StandCoordinate struct { Title string `json:"title"` Latitude float32 `json:"lat"` ...
package training import ( "encoding/json" "fmt" "io" "os" "strings" "text/tabwriter" yaml "gopkg.in/yaml.v2" "github.com/kubeflow/arena/pkg/apis/types" "github.com/kubeflow/arena/pkg/util" ) type SimpleJobInfo struct { Name string `json:"name" yaml:"name"` Status string `json:"status" yaml:"statu...
package main import "fmt" // 仅支持封装 不支持继承和多态 type TreeNode struct { i, j int } func main() { }
/* 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, so...
package ksuid import ( "testing" ) func TestStringPartitioner(t *testing. T) { p1 := StringPartitioner("test") p2 := StringPartitioner("part") if v1 := p1(); v1 != 0x74657374 { t.Errorf("Expected partition 0x74657374, got %08x\n", v1) t.Fail() } if v2 := p2(); v2 != 0x70617274 { t.Errorf("Expected par...
/* Alta3 Research | RZFeeser CHALLENGE 02 - Iterate across arguments passed in via the CLI */ package main import ( "fmt" "os" ) func main() { // the first argument i.e. program name is excluded via [1:] argLength := len(os.Args[1:]) // determine the length fmt.Printf("...
package main import ( "fmt" ) // 62. 不同路径 // 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。 // 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。 // 问总共有多少条不同的路径? // 提示: // 1 <= m, n <= 100 // 题目数据保证答案小于等于 2 * 10 ^ 9 // https://leetcode-cn.com/problems/unique-paths/ func main() { fmt.Println(uniquePaths2(3, 2)...
package main import ( "fmt" ) func main() { fmt.Println("heiehei") }
package freshdesk import ( "bytes" "encoding/json" "errors" "fmt" "net/http" ) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // TYPES, CONSTANTS // ////////////////////////////////////////////////////////////////////////////////////////////...
package mysql import ( "fmt" "log" "os" "gorm.io/driver/mysql" "gorm.io/gorm" ) type ConfigDB struct { User string Password string Host string Port string Database string } func (c *ConfigDB) InitDB() *gorm.DB { dsn := fmt.Sprintf("%v:%v@tcp(%v:%v)/%v?charset=utf8mb4&parseTime=True&loc=Local"...
package main // Effect: Linear Spectrum type LinearSpectrum struct { Effect sound *ProcessedAudio } func NewLinearSpectrum(disp Display, cg ColorGenerator, s *ProcessedAudio) *LinearSpectrum { ef := NewEffect(disp, 0.5, 0.0) e := &LinearSpectrum{ Effect: ef, sound: s, } e.Painter = cg return e } func (...
package listenutil import ( "balansir/internal/balanceutil" "balansir/internal/configutil" "balansir/internal/helpers" "balansir/internal/logutil" "balansir/internal/metricsutil" "context" "crypto/tls" "fmt" "net/http" "os" "os/signal" "strconv" "syscall" "time" "golang.org/x/crypto/acme/autocert" ) c...
// +build tools package tools import _ "github.com/codegangsta/gin"
package cmd import ( "github.com/learnergo/cuttle/invoke" "github.com/spf13/cobra" ) // genCmd represents the gen command var genCmd = &cobra.Command{ Use: "gen", Short: "generate certs", Long: "", Run: func(cmd *cobra.Command, args []string) { if args != nil && len(args) != 0 { if args[0] == "all" { ...
package main import ( "fmt" "io/ioutil" "os" "path/filepath" "github.com/drand/drand/core" "github.com/drand/drand/key" "github.com/drand/drand/net" control "github.com/drand/drand/protobuf/drand" json "github.com/nikkolasg/hexjson" "github.com/urfave/cli" ) // shareCmd decides whether the command is for ...
package utils import "testing" func TestDiff(t *testing.T) { a := []string{"hoge", "fugo"} b := []string{"hoge", "fugo", "hego"} c := []string{} if len(Diff(a, b)) != 0 { t.Fatalf("failed") } if len(Diff(b, a)) != 1 { t.Fatalf("faled") } if len(Diff(c, a)) != 0 { t.Fatalf("Failed") } }
package bmpipe import ( "github.com/alfredyang1986/blackmirror/bmmodel/request" "io" "net/http" ) type BMBrick struct { Next BMBrickFace Req *request.Request Pr interface{} Err int face BMBrickFace } type BMBrickFace interface { BrickInstance() *BMBrick Prepare(ptr interface{}) error Exec() error Don...
package entity import ( "github.com/jinzhu/gorm" ) //投稿記事テーブル用 //ユーザーが投稿した公開及び非公開記事のテーブルである。 type Post struct { gorm.Model //ID, CreatedAt, UpdatedAt, DeletedAtを自動で定義する Publishing int `gorm:"type:int;not null"` //公開設定 DogName string `gorm:"type:varchar(30);"` //犬の名前 Breed st...
// +build !windows package main func modDir(dir string) (string, error) { return dir, nil }
package init import ( "fmt" imdb "github.com/eefret/go-imdb" "github.com/sirupsen/logrus" "github.com/spf13/viper" ) var ( stage string im *imdb.OmdbApi ) // CommonInit initializes the common properties func CommonInit() { stage = getProperty("STAGE") } // getProperty is a common routine to bind and ret...
package twofer import "fmt" func ShareWith(person string) string { if person != "" { return fmt.Sprintf("One for %v, one for me.", person) } else { return "One for you, one for me." } }
package leetcode func matrixReshape(mat [][]int, r int, c int) [][]int { m := len(mat) n := len(mat[0]) if m*n != r*c { return mat } index := 0 newmat := makeMatrix(r, c) for i := 0; i < m; i++ { for j := 0; j < n; j++ { x := index / c y := index % c newmat[x][y] = mat[i][j] index++ } } re...
package repository import ( "time" "github.com/lenuse/mall/entity" "upper.io/db.v3" ) type PermissionRepository struct { entity.UmsPermission Roles RoleRepositoryList } type PermissionRepositoryList []PermissionRepository func (r *PermissionRepository) Init() error { roles, err := getRolesByPermissionId(r.Id...
package userspaced import ( "github.com/spf13/viper" "github.com/twa16/go-cas/client" ) var casServer gocas.CASServerConfig //initCAS Initializes connection to CAS server for ticket validation func initCAS() { casServer.ServerHostname = viper.GetString("CASURL") casServer.IgnoreSSLErrors = false }
package tsrv import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00200101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:tsrv.002.001.01 Document"` Message *UndertakingIssuanceAdviceV01 `xml:"UdrtkgIssncAdvc"` } func (d *Document002...
package main import "testing" func TestExecute(t *testing.T) { tests := []struct { Name string Program Memory Expected Memory }{ { Name: "detailed example", Program: Memory{ 1, 9, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50, }, Expected: Memory{ 3500, 9, 10, 70, 2, 3, 11, 0, 99, 30, 40, 50, ...
package main import ( "fmt" "log" "github.com/go-playground/form/v4" ) // A ... type A struct { Field string } // B ... type B struct { A Field string } // use a single instance of Encoder, it caches struct info var encoder *form.Encoder func main() { type A struct { Field string } type B struct { ...
package main import ( "fmt" "os" ) func main() { fmt.Println("panic testing") /* When the function F calls panic, execution of F stops, any deferred functions in F are executed normally, and then F returns to its caller. */ panic("a problem") _, err := os.Create("asu") if err != nil { fmt.Println("asuu"...
package main import ( "log" "net/http" "go-cqrs/db" "go-cqrs/messaging" "go-cqrs/util" "github.com/gorilla/mux" ) func newRouter() (router *mux.Router) { router = mux.NewRouter() router.HandleFunc("/woofs", woofsHandler).Methods("POST") return } func main() { defer db.Close() defer messaging.Close() //...
package s3 import ( "bytes" "fmt" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" awss3 "github.com/aws/aws-sdk-go/service/s3" "github.com/codeformuenster/dkan-newest-dataset-notifier/externalservices" ) type S3 struct { svc *aws...
package ratelimit import ( "errors" "github.com/Highway-Project/highway/pkg/middlewares" "github.com/patrickmn/go-cache" "net" "net/http" "time" ) type RateLimitMiddleware struct { db *cache.Cache rateLimitValue int strategyFunc func(r *http.Request) string rateLimitDuration time.Dura...
// Copyright 2016 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
package dock import ( "github.com/ssgo/s" "net/http" "strings" "fmt" "time" ) func Registers() { s.SetAuthChecker(auth) s.Static("/", "www") s.Restful(0, "POST", "/login", login) s.Restful(1, "GET", "/nodes/status", getNodeStatus) s.Restful(1, "GET", "/nodes", getNodeList) s.Restful(1, "GET", "/contexts",...
package core type Service interface { Lifecycle Start() chan error Stop() chan error } func NewServiceManager() *ServiceManager { s := &ServiceManager{} s.services = make(map[interface{}]Service, 0) return s } type ServiceManager struct { services map[interface{}]Service } func (sm *Service...
package model import ( "github.com/feast-dev/feast/go/protos/feast/core" ) type Entity struct { Name string JoinKey string } func NewEntityFromProto(proto *core.Entity) *Entity { return &Entity{ Name: proto.Spec.Name, JoinKey: proto.Spec.JoinKey, } }
package main import ( "fmt" "log" "math" "sort" common "github.com/linus4/csgoverview/common" demoinfo "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/common" "github.com/veandco/go-sdl2/gfx" "github.com/veandco/go-sdl2/sdl" ) type PlaybackIcon struct { Icon rune YOffset int32 } const ( radi...