text
stringlengths
11
4.05M
package cmd import ( "bufio" "bytes" "fmt" "os" "time" pub "github.com/go-ap/activitypub" pubcl "github.com/go-ap/client" "github.com/go-ap/errors" "github.com/go-ap/fedbox/app" "github.com/go-ap/fedbox/internal/config" "github.com/go-ap/fedbox/internal/env" "github.com/go-ap/processing" "github.com/go-a...
package main import ( "log" "net/http" "os" "github.com/connorjcantrell/toolint/postgres" "github.com/connorjcantrell/toolint/web" ) func main() { dsn := os.Getenv("TOOLINT_DB") store, err := postgres.NewStore(dsn) if err != nil { log.Fatal(err) } sessions, err := web.NewSessionManager(dsn) if err != n...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package aws import ( "context" "github.com/aws/aws-sdk-go-v2/service/ec2" ) // EC2API represents the series of calls we require from the AWS SDK v2 EC2 Client type EC2API interface { CreateTags(ctx ...
package purchaseorderapi import ( "encoding/json" "errors" "fmt" "io/ioutil" "net/http" "strings" "github.com/dolittle/platform-api/pkg/platform" "github.com/dolittle/platform-api/pkg/platform/microservice/k8s" "github.com/dolittle/platform-api/pkg/platform/microservice/parser" "github.com/dolittle/platform...
package main import ( "flag" "net" log "github.com/sirupsen/logrus" "github.com/shimmerglass/rgbx/device" "github.com/shimmerglass/rgbx/render" "github.com/shimmerglass/rgbx/rgbx" "github.com/shimmerglass/rgbx/server" "google.golang.org/grpc" ) func main() { listen := flag.String("listen", "127.0.0.1:1342"...
// Copyright 2020 The VectorSQL Authors. // // Code is licensed under Apache License, Version 2.0. package planners import ( "testing" "parsers" "parsers/sqlparser" "github.com/stretchr/testify/assert" ) func TestShowTablesPlan(t *testing.T) { query := "show tables where names like 'xx' limit 2" statement, e...
package keybindings import ( "errors" "../printout" "../layout" "../ds" "../file" "strings" "github.com/jroimartin/gocui" ) func prompt_Entry_Date(g *gocui.Gui, v *gocui.View) error { var err error if err = layout.Create_Prompt_View(g, "entryDate", "[Entry Date ]", true); err != nil { return err } ...
// Copyright (C) 2016-Present Pivotal Software, Inc. All rights reserved. // This program and the accompanying materials are made available under the terms of the 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 Licen...
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package pcap import ( "context" "fmt" "os" "path/filepath" "chromiumos/tast/common/network/tcpdump" "chromiumos/tast/common/wificell/router" "chromiumos/tast/errors"...
/* * 存储后端接口 */ package cachex import "time" // Storage 存储后端接口 type Storage interface { // Get 获取缓存的数据。value必须是非nil指针。没找到返回NotFound;数据已经过期返回过期数据加NotFound Get(key, value interface{}) error // Set 缓存数据 Set(key, value interface{}) error } // DeletableStorage 支持删除操作的存储后端接口 type DeletableStorage interface { Stora...
package main import ( "fmt" "github.com/gin-gonic/gin" ) func main() { r := gin.Default() v1 := r.Group("v1") { v1.GET("/login", login) v1.GET("/submit", submit) } v2 := r.Group("v2") { v2.POST("/login", login) v2.POST("/submit", submit) } r.Run(":8888") } func login(c *gin.Context) { name := ...
package microservicesconfiguration import ( "crypto/tls" "encoding/json" "fmt" "io/ioutil" "log" "net/http" "strings" "sync" "time" ) type springCloudConfig struct { Name string `json:"name"` Profiles []string `json:"profiles"` Label string `json:"la...
package main import ( "fmt" "log" ) func printError(err error, format string, v ...interface{}) { log.Printf("ERROR: %s error: %v", fmt.Sprintf(format, v...), err) } func printInfo(format string, v ...interface{}) { log.Printf("INFO: %s", fmt.Sprintf(format, v...)) }
package main import ( "bytes" "context" "encoding/csv" "encoding/json" "flag" "fmt" "github.com/sfomuseum/go-flags/multi" "github.com/whosonfirst/go-whosonfirst-feature/properties" "github.com/whosonfirst/go-whosonfirst-travel/traveler" "io" "log" "os" "sort" "strconv" "strings" "sync" ) // please mov...
package sender import ( cutils "github.com/open-falcon/falcon-plus/common/utils" "github.com/open-falcon/falcon-plus/modules/transfer/g" rings "github.com/toolkits/consistent/rings" ) func initNodeRings() { cfg := g.Config() JudgeNodeRing = rings.NewConsistentHashNodesRing(int32(cfg.Judge.Replicas), cutils.Keys...
package service import ( "github.com/16francs/examin_go/domain/model" "github.com/16francs/examin_go/domain/repository" ) // TProblemService - 講師向け 問題集 モデルの操作 type TProblemService interface { CreateProblem(problem *model.Problem) (*model.Problem, error) } type tProblemService struct { repository repository.TProb...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package store import ( "net/url" "os" "testing" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func makeUnmigratedTestSQLStore(tb te...
package slack import ( "fmt" "io/ioutil" "net/http" "github.com/labstack/echo/v4" "github.com/slack-go/slack/slackevents" ) func (h handlerImpl) SlackEvents(c echo.Context) error { ctx := c.Request().Context() r := c.Request() w := c.Response() body, err := ioutil.ReadAll(r.Body) if err != nil { fmt.Prin...
package main import ( "TPForum/internal/app/server" "TPForum/internal/pkg/config" ) func main() { server.RunServer(config.Get().Main.Port) }
package process import ( "fmt" "net/url" "regexp" "strings" "sync" "github.com/jasontconnell/crawl/data" ) var hrefRegex *regexp.Regexp = regexp.MustCompile(`(href|src)="(.*?)"`) func parse(site *data.Site, referrer, content string, gatheredUrls *sync.Map) []data.Link { urls := []data.Link{} matches := href...
package main import ( "fmt" "io/ioutil" "os" "github.com/kardianos/service" "github.com/sirupsen/logrus" ) // HookLogger routes the logrus logs through the service logger so that they end up in the Windows Event Viewer // logrus output will be discarded func HookLogger(l *logrus.Logger) { l.AddHook(newLogHook(...
package sdp import ( "bufio" "io" "strconv" "time" ) type reader interface { ReadLine() (string, error) } // A Decoder reads and decodes SDP description from an input stream or buffer. type Decoder struct { r reader p []string err error } // NewDecoder returns a new decoder that reads from r. func NewDe...
package main import ( "fmt" "phrasefinder" // "github.com/mtrenkmann/phrasefinder-client-go/src/phrasefinder" ) func main() { // Set up your query. query := "I like ???" // Set the optional parameter topk to 10. options := phrasefinder.DefaultOptions() options.Topk = 10 // Perform a request. result, err ...
package oddtype type Hha struct { A string `json:"A" odd:"type=hha"` H string `json:"H" odd:"type=hha"` D string `json:"D" odd:"type=hha"` ID string `json:"ID" odd:"id"` POOLSTATUS string `json:"POOLSTATUS"` INPLAY string `json:"INPLAY"` ALLUP string `json:"ALLUP"` H...
package images import ( "errors" "github.com/joonazan/imagick/imagick" "path/filepath" "testing" ) func TestResize1(t *testing.T) { doTest(t, "toresize.jpg", "resized.jpg", true) } func TestResize2(t *testing.T) { doTest(t, "toresize2.jpg", "resized2.jpg", true) } func TestResize3(t *testing.T) { doTest(t, "...
package odoo import ( "fmt" ) // AccountReconcileModelTemplate represents account.reconcile.model.template model. type AccountReconcileModelTemplate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` AccountId *Many2One `xmlrpc:"account_id,omptempty"` Amount *Float `xmlr...
package cloudformation // AWSECSTaskDefinition_HealthCheck AWS CloudFormation Resource (AWS::ECS::TaskDefinition.HealthCheck) // See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-taskdefinition-healthcheck.html type AWSECSTaskDefinition_HealthCheck struct { // Command AWS CloudFor...
package blockchain import ( "github.com/hyperledger/burrow/crypto" ) type ValidatorsWindow struct { Buckets []Validators Total Validators head int } // Provides a sliding window over the last size buckets of validator power changes func NewValidatorsWindow(size int) ValidatorsWindow { if size < 1 { size ...
package models type Plan struct { PlanId string `json:"plan_id"` PlanName string `json:"plan_name"` Lob string `json:"lob"` } type Level struct { LevelId string `json:"level_id"` LevelName string `json:"level_name"` LevelType string `json:"level_type"` Lob string `json:"lob"` LevelValues...
package nodefindergo import ( "fmt" "os" "path" "reflect" "testing" "github.com/zxjsdp/nodefinder-go/nodefindergo" ) var ( rawTree string = "((a, ((b, c), (ddd,\t e))), (f, g));\n\n" cleanTree string = "((a,((b,c),(ddd,e))),(f,g));" nameA string = "ddd" nameB string = "b" caliInfo str...
package cli import ( "bufio" "fmt" "os" "strings" ) // Prompt is a simple implementation of keepassrpc.Passworder. func Prompt() (string, error) { reader := bufio.NewReader(os.Stdin) fmt.Print("Enter the code provided by KeePass: ") text, err := reader.ReadString('\n') if err != nil { return "", err } ret...
// Copyright 2019 Intel Corporation. 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 app...
package paymentrequest import ( "database/sql" "fmt" "time" "github.com/benbjohnson/clock" "github.com/gobuffalo/pop/v5" "go.uber.org/zap" "github.com/transcom/mymove/pkg/services/invoice" "github.com/transcom/mymove/pkg/db/sequence" ediinvoice "github.com/transcom/mymove/pkg/edi/invoice" "github.com/tran...
package main import ( "github.com/stretchr/testify/assert" "testing" ) func TestAlphasCase0(t *testing.T) { in := "All your base are belong to us." exp := "@11 `/0|_||Z 8@$3 @|Z3 8310[]\\[]6 ']['0 |_|$." assert.Equal(t, exp, ConvAlphabet(in), "FeelsUnluckyMan") } func TestAlphasCase1(t *testing.T) { in := "Wha...
// SPDX-License-Identifier: ISC // Copyright (c) 2014-2020 Bitmark Inc. // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package messagebus import ( "container/list" "fmt" "reflect" "strconv" "sync" "golang.org/x/crypto/sha3" ) // for select the default queue ...
package main import ( "fmt" "gopkg.in/go-playground/validator.v9" ) var v = validator.New() func validate(item interface{}) error { err := v.Struct(item) if err != nil { if _, ok := err.(*validator.InvalidValidationError); ok { return err } for _, err := range err.(validator.ValidationErrors) { re...
package admin import ( "myapp/models" "time" "fmt" "myapp/util" ) type RoleController struct { baseController } func (this *RoleController) Index() { var ( page int pagesize int = 8 offset int role_list []*models.Role ) if page, _ = this.GetInt("page"); page < 1 { page = 1 }...
package command import ( "fmt" "path/filepath" "github.com/codegangsta/cli" "github.com/dnaeon/gru/module" "github.com/gosuri/uitable" ) // NewModuleCommand creates a new sub-command for // displaying the list of available modules func NewModuleCommand() cli.Command { cmd := cli.Command{ Name: "module", ...
package core import ( "fmt" "math/rand" "os" "os/exec" ) const DeadCell = 0 const LivingCell = 1 const GrowingCell = 2 const DyingCell = 3 type Map struct { cells [][]int } func (myMap *Map) Initialize(size int) { myMap.cells = make([][]int, size) for i := 0; i < size; i++ { myMap.cells[i] = make([]int, s...
package main import ( "flag" "is105gruppe20/is105-ica03/bfrequence" ) func main() { var filnavn string flag.StringVar(&filnavn, "f", "", "Name of file to be inspected") flag.Parse() bfrequence.BuffFileInfo(filnavn) }
package dbtool import ( "fmt" "os" "time" ) type ( // Config config for postgres tool Config struct { DBName string DBUser string DBPass string Host string Port string } ) // CreateMigrationFile createa migration file func CreateMigrationFile(migrationSrc, name string) { epoch := time.Now().Unix...
/* * @lc app=leetcode.cn id=312 lang=golang * * [312] 戳气球 */ // @lc code=start func maxCoins(nums []int) int { size := len(nums) points := make([]int, size+2) points[0] = 1 points[size+1]=1 for i := 1; i < size+1; i++ { points[i] = nums[i-1] } // 定义dp数组 dp := make([][]int,size+2) for i := 0; i < (size+...
package middlewares import ( "time" "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" ) func Ginrus(logger *logrus.Logger) gin.HandlerFunc { return func(c *gin.Context) { start := time.Now() // some evil middlewares modify this values path := c.Request.URL.Path c.Next() end := time.Now() laten...
package problems import ( "modelos/table" ) func (p *P) Iterate() string { s := "" if p.Minmax == Max { positives, j := AllPositives(p.T.Zks, p.T.N+p.T.M) for !positives { s += "\n\n" + i(p.T, j) positives, j = AllPositives(p.T.Zks, p.T.N+p.T.M) } } return s } func (p *P) IterateD() string { s := "...
package main import ( "context" "flag" "fmt" "time" "github.com/testlinkerd/pkg/world" "google.golang.org/grpc" ) var ( target = flag.String("target", ":50040", "specify target") ) func main() { flag.Parse() cc, err := grpc.Dial( *target, grpc.WithInsecure(), ) if err != nil { panic(err) } defe...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package helm import ( "os/exec" "strings" "github.com/pkg/errors" ) // RunGenericCommand runs any given helm command. func (c *Cmd) RunGenericCommand(arg ...string) error { _, _, err := c.run(arg.....
package config import ( "fmt" "github.com/spf13/viper" ) type Config struct { Database struct { MongoDB struct { URL string `json:"url"` Name string `json:"name"` } `json:'mongodb"` } `json:"database"` } func Loader() *Config { var conf Config viper.SetConfigName("config") // name of config file (...
package handlers import ( "encoding/json" "io/ioutil" "net/http" "github.com/CassioRoos/poc-lazy-loading/models" "github.com/CassioRoos/poc-lazy-loading/services" ) type Withdraw struct { service services.WithdrawService } func NewWithdraw(service services.WithdrawService) *Withdraw { return &Withdraw{servic...
package rbac import ( "fmt" //"errors" //"time" . "cms_admin/admin/src/lib" m "cms_admin/admin/src/models" ) type UserController struct { CommonController } func (this *UserController) List() { page, _ := this.GetInt64("page") page_size, _ := this.GetInt64("page_size") sort := this.GetString("sort") order ...
package service import ( . "imageserver/models" "github.com/emicklei/go-restful" "strconv" "encoding/json" "io/ioutil" "net/http" ) // Запросы категорий func (self *App) routNeuralReply(req *restful.Request, resp *restful.Response) { id, err := strconv.ParseInt(req.PathParameter("id"), 10, 64) if err != nil { ...
package main import ( "errors" "fmt" "go/ast" "log" ) func (g *Gen) mapGenNKeys(n string, count int) error { err := mapUnmarshalTpl["nKeys"].tpl.Execute(g.b, struct { NKeys int StructName string }{ NKeys: count, StructName: n, }) return err } func (g *Gen) mapGenUnmarshalObj(n string, s *as...
// Copyright 2020 The VectorSQL Authors. // // Code is licensed under Apache License, Version 2.0. package http import ( "fmt" "io/ioutil" "net/http" "config" "base/errors" "base/xlog" ) type HTTPHandler struct { httpServer *http.Server log *xlog.Log conf *config.Config } func NewHTTPHandler...
package main import ( "crypto/rand" "crypto/tls" "crypto/x509" "log" "net" "net/rpc" ) func main() { cert, err := tls.LoadX509KeyPair("server1.crt", "server.key") if err != nil { log.Fatalf("Error: %s when load server keys", err) } if len(cert.Certificate) != 2 { log.Fatal("server1.cr...
/* * Copyright 2018 The NATS 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...
package models type Keyboard struct { OneTime bool `json:"one_time"` Inline bool `json:"inline"` Buttons [][]Button `json:"buttons"` } type Button struct { Action `json:"action"` Color string `json:"color,omitempty"` } type Action struct { Type string `json:"type"` Label string `json:"label...
package Week_02 func preorderTraversal(root *TreeNode) []int { res := make([]int, 0) res = helper(root) return res } func helper2(root *TreeNode) []int { r := make([]int, 0) if root != nil { r = append(r, root.Val) if root.Left != nil { r = append(r, helper(root.Left)...) } if root.Right != nil { r...
package main import ( "context" "encoding/json" "os" //"encoding/json" "flag" "fmt" "log" "time" "github.com/BurntSushi/toml" "github.com/dgraph-io/dgo" "github.com/dgraph-io/dgo/protos/api" "github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx/types" _ "github.com/lib/pq" "google.golang.org/grpc" ) typ...
// Copyright © 2020 author from config // // 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 main import ( "github.com/markberger/tally" ) func main() { tally.InitLogging() bot := tally.NewBot() bot.Connect() bot.Run() }
package main import "fmt" //归并排序:是一种分治思想,应用递归编程技巧来实现 //递推公式:mergeSort(p...r) = merge(mergeSort(p..q),mergeSort(q...r)),p>=r 停止 func mergeSort(a []int32, n int32) { mergeSort_go(a, 0, n-1) } func mergeSort_go(a []int32, p int32, r int32) { if p >= r { return } q := (p + r) / 2 mergeSort_go(a, p, q) mergeSor...
package main import ( "net/http" "fmt" "mime" "io" "encoding/json" "mime/multipart" "github.com/gorilla/mux" "github.com/urfave/negroni" "github.com/mitchellh/goamz/aws" "github.com/mitchellh/goamz/s3" ) type VideoMetadata struct{ Id string } type ContentRangeHeader struct{ Start int End int Total int...
package sql import ( "github.com/phogolabs/orm/dialect/sql/scan" ) // DeleteMutation represents a delete mutation type DeleteMutation struct { builder *DeleteBuilder } // NewDelete creates a Mutation that deletes the entity with given primary key. func NewDelete(table string) *DeleteMutation { return &DeleteMutat...
package api import ( "net/http" "github.com/ken-aio/go-echo-base/model" "github.com/Sirupsen/logrus" "github.com/labstack/echo" . "gopkg.in/check.v1" ) func (s *ApiSuite) Test_PostXxx(c *C) { expectedName := "Test_PostXxx" xxx_json := `{"name":"` + expectedName + `"}` context, rec := buildContext(c, echo.PO...
// author: ashing // time: 2019/12/25 12:08 下午 // mail: axingfly@gmail.com // Less is more. package route import ( "github.com/gin-gonic/gin" "github.com/ronething/mp-wechat-go/controller" ) func Register(g *gin.Engine) { g.Use(gin.Recovery()) g.Use(gin.Logger()) registerApi(g) } func registerApi(g *gin.Engi...
package files import ( "bufio" "fmt" "log" "os" "strings" ) const initialFileContent = `# %s ## %s ## %s ## %s ` var validPrefixes = [...]string{ // Board Name "# ", // List Name "## ", // Task "- ", // Task Description "> ", // Subtask "* ", } // CheckFile checks if the file(taskgo.md) is pre...
import "sort" /* * @lc app=leetcode id=561 lang=golang * * [561] Array Partition I * * https://leetcode.com/problems/array-partition-i/description/ * * algorithms * Easy (71.69%) * Likes: 796 * Dislikes: 2463 * Total Accepted: 211.6K * Total Submissions: 294.9K * Testcase Example: '[1,4,3,2]' * *...
// Copyright 2021 The Perses 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 ...
package gbvideo import ( "time" "github.com/Lavos/gbvideo/giantbomb" ) type VideoDownload struct { giantbomb.Video DownloadDate *time.Time Queued bool }
package lxd import "net/http" import "log" import "crypto/tls" import "time" import "cointhink/config" func NewClient() http.Client { certFile := config.C.QueryString("lxd.certFile") keyFile := config.C.QueryString("lxd.keyFile") cert, err := tls.LoadX509KeyPair(certFile, keyFile) if err != nil { log.Fatal(e...
/** * @website: https://vvotm.github.io * @author luowen<bigpao.luo@gmail.com> * @date 2017/12/26 20:52 * @description: */ package request type ReqReplies struct { JokerId int `json:"jokerId" form:"jokerId" query:"jokerId" validate:"required"` Uid int `json:"uid" form:"uid" query:"uid" validate:"required"` C...
package ds var KConfig Config type Config struct { LogPath string ShowDisabled bool Mode int TodosOnly bool }
package state import "time" // PostgresVacuumProgress - PostgreSQL vacuum thats currently running // // See https://www.postgresql.org/docs/10/static/progress-reporting.html type PostgresVacuumProgress struct { VacuumIdentity uint64 // Combination of vacuum "query" start time and PID, used to identify a vacuum over...
package gerrit import ( "strconv" "time" ) // These types are based on the entity definitions at // https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html , // https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html , etc. // Note that although they represent much the same th...
package search import ( "encoding/json" "os" ) const dateFile = "data/data.json" //Feed包含我们需要处理的数据源的信息 type Feed struct { Name string `json:"site"` URI string `json:"link"` Type string `json:"type"` } //RetrieveFeeds读取并反序列化源数据文件 func RetrieveFeeds()([]*Feed,error) { //打开 文件 file,err := os.Open(dateFile) i...
// Copyright (C) 2017 Google 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 t...
package main import ( "reflect" "testing" ) func TestSmallest(t *testing.T) { type args struct { n int64 } tests := []struct { name string args args want []int64 }{ {name: "1", args: args{n: 261235}, want: []int64{126235, 2, 0}}, {name: "2", args: args{n: 209917}, want: []int64{29917, 0, 1}}, {nam...
package printer type PrintableList interface { ToJson() string ToHtml() string ToTable() string } type Printable interface { }
package mining import ( "../account" "../block" "log" "testing" ) func TestMineBig(t *testing.T) { miner := account.CreateAccount() bl := block.GetTestBlock() privKey := account.RestorePrivKey(miner.PrivateKey) log.Print("Start minig...") MineBig(&bl, privKey) log.Print(bl) }
package main import ( "fmt" "github.com/abnereel/lottery/bootstrap" "github.com/abnereel/lottery/web/middleware/identity" "github.com/abnereel/lottery/web/routes" ) var port = 8080 func newApp() *bootstrap.Bootstrapper { // 初始化应用 app := bootstrap.New("Go抽奖系统", "Abner") app.Boostrap() app.Configure(identity.C...
package filecreator import ( "io/ioutil" "log" "os" _ "github.com/joho/godotenv/autoload" ) // ImportHTMLToFile ... func ImportHTMLToFile(code string, token string) { // Files have to be created there because they have to be in the same level or further than the main index.html which is in public directory pat...
// Homework 4: Concurrency // Due February 21, 2017 at 11:59pm package main import ( "bufio" "fmt" "io" "log" "os" "strconv" "strings" "sync" ) func main() { // Feel free to use the main function for testing your functions hello := map[string]string{ "こんにちは": "世界", "你好": "世界", "안녕하세요": "세계", } fo...
// Copyright 2021 The LUCI 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...
package main import "flag" var equipo = flag.String("equipo", "resuelve.json", "El equipo a analizar") var niveles = flag.String("niveles", "niveles.json", "Los niveles con los cuales calcular") func main() { flag.Parse() abrir(*equipo, *niveles) }
package create import ( "encoding/json" "fmt" "net/http" "github.com/ocoscope/face/db" "github.com/ocoscope/face/utils" "github.com/ocoscope/face/utils/answer" "github.com/ocoscope/face/utils/recognition" ) func Visit(w http.ResponseWriter, r *http.Request) { type tbody struct { UserID, CompanyID int64 ...
package redisearch import ( "sort" "strings" ) const ( field_tokenization = ",.<>{}[]\"':;!@#$%^&*()-+=~" ) // Document represents a single document to be indexed or returned from a query. // Besides a score and id, the Properties are completely arbitrary type Document struct { Id string Score floa...
package metas import ( "fmt" "testing" ) func Test_RangePartitionItem(t *testing.T) { name1 := "p_01" values := []interface{}{0, '1', "a"} part1 := NewRangePartitionItem(name1, values, false) part1Str, err := part1.GetMetaStr() if err != nil { t.Fatal(err.Error()) } fmt.Println(part1Str) nameMax := "p_ma...
package block import ( "bytes" "encoding/gob" "time" "github.com/yopming/Berify/util" ) // Block represents a block in the blockchain type Block struct { Timestamp int64 Transactions []*Transaction PreviousBlockHash []byte Hash []byte Nonce int Height int } ...
package deck import ( "errors" "math/rand" "github.com/google/uuid" "toggl-card/internal/card" ) // Deck is defined as a cobination of card objects type Deck struct { ID uuid.UUID `json:"deck_id"` Shuffled bool `json:"shuffled"` Remaining int `json:"remaining"` Cards []card.Card `...
package server import ( "bytes" "context" "crypto/tls" "encoding/gob" "errors" "log" "net" "net/http" "sync" "golang.org/x/net/http2" "golang.org/x/net/websocket" "golang.org/x/tools/godoc/vfs" "golang.org/x/tools/godoc/vfs/mapfs" "github.com/donovanhide/eventsource" "github.com/neelance/gopath-tunnel...
package jago /*21 (0X15)*/ func ILOAD(opcode uint8, f *Frame, t *Thread, c *Class, m *Method) { index := f.index8() f.push(f.loadVar(uint(index)).(Int)) } /*22 (0X16)*/ func LLOAD(opcode uint8, f *Frame, t *Thread, c *Class, m *Method) { index := f.index8() f.push(f.loadVar(uint(index)).(Long)) } /*23 (0X17)*/ f...
package main type Resolver struct{} type ThreadResolver struct { thread Thread } func (t *ThreadResolver) id() *string { return &t.thread.id } func (t *ThreadResolver) author() *string { return &t.thread.author } func (t *ThreadResolver) title() *string { return &t.thread.title } func (t *ThreadResolver) date_p...
package passingcars import "testing" func TestPassingCars(t *testing.T) { entries := []struct { input []int result int }{ {[]int{0, 1, 0, 1, 1}, 5}, {[]int{1, 0}, 0}, } for _, entry := range entries { result := PassingCars(entry.input) // check if result and expected result are same if entry.re...
package _0_Decorator_Pattern import ( "../01_Factory_Pattern" ) //步骤 1 //创建一个接口: type Shape = _1_Factory_Pattern.Shape //步骤 2 //创建实现接口的实体类。 type Rectangle = _1_Factory_Pattern.Rectangle type Circle = _1_Factory_Pattern.Circle //步骤 3 //创建实现了 Shape 接口的抽象装饰类。 type ShapeDecorator interface { Draw() string setDecorat...
package main import ( "log" "net/http" ) type statusWriter struct { http.ResponseWriter status int } func (w *statusWriter) WriteHeader(status int) { w.status = status w.ResponseWriter.WriteHeader(status) } func RequestLogger(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWrite...
package service import "github.com/jerolan/slack-poll/domain/entity" type PollService interface { GetPollByID(pollID string) (entity.Poll, error) CreatePoll(*entity.Poll) error DeletePoll(pollID string) error FindPollAnswers(pollID string) ([]entity.PollAnswer, error) CreatePollAnswer(*entity.PollAnswer) error ...
package adapter import "fmt" type Wireles struct { } func (w Wireles) WirelessCharging() { fmt.Println("The device is charging using wireless charging.") }
package faregate import ( "fmt" "math/rand" "time" ) func Must(c <-chan struct{}, err error) <-chan struct{} { if err != nil { panic(err) } return c } func Example() { rnd := rand.New(rand.NewSource(42)) fg, err := New(RefreshInterval(time.Second), TokenCount(100), ConcurrencyLevel(1)) if err != nil { ...
package main import ( "encoding/json" "fmt" ) func main() { type Pessoa struct { Nome string Idade int } p1 := Pessoa{"Paula", 42} sliceBytes, err := json.Marshal(p1) if err != nil { fmt.Println(err) } fmt.Println(string(sliceBytes)) }
package main import ( "encoding/json" "errors" "github.com/satori/go.uuid" "sort" "sync" ) type Application struct { UniqueId string `json:"id" bson:"_id,omitempty"` Name string `json:"name" bson:"name"` BaseUrl string `json:"baseUrl" bson:"baseUrl"` Se...
package taskfile_test import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gopkg.in/yaml.v3" "github.com/go-task/task/v3/taskfile" ) func TestPreconditionParse(t *testing.T) { tests := []struct { content string v any expected any }{ { "test -f foo....