text
stringlengths
11
4.05M
package handler import ( "encoding/json" "net/http" "github.com/gorilla/mux" "github.com/hippojamba/go-rest/app/model" ) var posts []model.Post func GetPosts(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(posts) } func GetPost(w http.ResponseWriter, r *http.Request) { params := mux.Vars(...
package main import ( "fmt" "strconv" "strings" ) func charts() [3]string { charts := [3]string{"bar", "pie", "radar"} return charts } func makeChart(data [][]string) string { var chart string switch selectChart() { case "bar": chart = barChart(data) case "pie": chart = pieChart(data) case "radar": ...
package main import ( "bufio" "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "net/http/cookiejar" "os" "strconv" "strings" "syscall" "time" "unsafe" "github.com/dlclark/regexp2" "github.com/gookit/color" ) var ( client = &http.Client{} cookieClient = &http.Client{} in = color....
package query import ( "bytes" "fmt" "strconv" "strings" "github.com/inappcloud/query/where" ) type updateQuery struct { table string fields []string values []interface{} limit int offset int conditions *where.Condition returning string } func (q *updateQuery) Fields(fields string...
// Copyright (c) 2016-2019 Uber 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...
// ้ๅކ J๏ผŒๅฐ†ๅ…ƒ็ด ๅญ˜ๅ‚จๅœจ map ไธญ // ้ๅކ S๏ผŒๅฆ‚ๆžœๅ…ƒ็ด ๅœจ map ไธญ๏ผŒcount++ package numjewelsinstones func numJewelsInStones(J string, S string) int { var count int var jMap map[rune]bool jMap = make(map[rune]bool) for _, v := range J { jMap[v] = true } for _, v := range S { if _, ok := jMap[v]; ok { count++ } } return count }...
package builder import ( "errors" "reflect" "strings" "testing" kapi "k8s.io/kubernetes/pkg/api" "github.com/openshift/origin/pkg/build/api" "github.com/openshift/origin/pkg/client/testclient" "github.com/openshift/origin/pkg/generate/git" s2iapi "github.com/openshift/source-to-image/pkg/api" s2ibuild "git...
package pipelineinpod import ( "context" "fmt" cprv1alpha1 "github.com/tektoncd/experimental/pipeline-in-pod/pkg/apis/colocatedpipelinerun/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" clientset "github.com/tektoncd/pipeline/pkg/client/client...
package chord type IntervalNumber string const ( Third = IntervalNumber("") Triad = Third Fifth = IntervalNumber("โต") Indeterminate = Fifth Neutral = Fifth Sixth = IntervalNumber("โถ") Seventh = IntervalNumber("โท") Ninth = IntervalNumber("โน") Eleventh =...
package dbtool import ( gp "code.google.com/p/goprotobuf/proto" "code.google.com/p/snappy-go/snappy" "common" "connector" "database/sql" "fmt" "hash/crc32" "io" "logger" "os" "proto" "rpc" "stats" "strconv" "strings" "sync" "time" ) const ( keylen = 64 ) type table struct { name string ca...
package pool import ( "log" ) type Pool struct { Queue chan func() error Number int Size int result chan error finishCallback func() } func (pool *Pool) Init(number int, size int) { pool.Queue = make(chan func() error, size) pool.Number = number pool.Size = size pool.result = make(chan error, s...
package user import( "github.com/gin-gonic/gin" "m/models/user" "net/http" "strconv" ) func PostUser(ctx *gin.Context) { ctx.Header("Access-Control-Allow-Origin", "*") un := ctx.PostForm("UserName") um := ctx.PostForm("UserMailaddress") up := ctx.PostForm("UserPassword") ur, _ := strconv.Atoi(ctx.PostForm("U...
package preload import ( "reflect" "strings" "testing" "time" "github.com/foxcpp/go-mtasts" ) // From https://github.com/EFForg/starttls-everywhere/blob/master/RULES.md const sampleList = `{ "timestamp": "2014-06-06T14:30:16.000000+00:00", "author": "Electronic Frontier Foundation https://eff.org", "expir...
package dispatcherinterface import ( "github.com/ssucc/goasyncsvr/base" "github.com/ssucc/goasyncsvr/netinterface" "github.com/ssucc/goasyncsvr/packet" ) type IDispatcher interface { GetConf(pid int32) *base.Conf DispatchTimeTout(timeout int32) Dispatch() DispatchReqMsg(pkg *packet.Packet, c netinterface.IConn...
package main import "testing" func TestHelloReturnsHello(t *testing.T) { got := Hello() want := "Hello" if got != want { t.Fatalf("Hello() = %v, but got %v\n", want, got) } }
// Copyright 2020 The Moov Authors // Use of this source code is governed by an Apache License // license that can be found in the LICENSE file. package admi_v02 import ( "encoding/xml" "github.com/moov-io/iso20022/pkg/common" "github.com/moov-io/iso20022/pkg/utils" ) type Event2 struct { EvtCd common.Max4Al...
// Copyright 2015 go-swagger maintainers // // 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 agr...
package main import ( "fmt" "math" ) func max(n1, n2 int) int { if n1 > n2 { return n1 } return n2 } func swap(x, y string) (string, string) { return y, x } func swap_address(x, y *int) { temp := *x *x = *y *y = temp } func getSequence() func() int { i := 0 return func() int { i++ return i } } t...
package messaging_test import ( "encoding/json" "io/ioutil" "net/http" "net/http/httptest" "net/url" "os" "reflect" "strings" "testing" "github.com/influxdb/influxdb/messaging" ) // Ensure a client can open the configuration file, if it exists. func TestClient_Open_WithConfig(t *testing.T) { // Write conf...
package pipeline import ( "bufio" "net" ) func NetWorkSink(addr string,in <- chan int){ linsen,err:=net.Listen("tcp",addr) if err!=nil{ panic(err) } go func() { defer linsen.Close() conn,err:=linsen.Accept() if err!=nil{ panic(err) } defer conn.Close() writer:=bufio.NewWriter(conn) defer wr...
package wxpay import ( "encoding/xml" "github.com/nilorg/sdk/random" ) // https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2 // PromotionTransfersRequest ไผไธšๅ‘ๅพฎไฟก็”จๆˆทไธชไบบไป˜ๆฌพ่ฏทๆฑ‚ type PromotionTransfersRequest struct { XMLName xml.Name `xml:"xml"` MchAppID string `xml:"mch_appid"` MchID ...
package cluster import ( "fmt" "github.com/latam-airlines/crane/configuration" "github.com/latam-airlines/crane/core" "github.com/stretchr/testify/assert" "net/http" "net/http/httptest" "testing" ) func TestDockerUserRestriction_Config(t *testing.T) { tests := []struct { config *configuration.Paramet...
package zkledger import ( "fmt" "log" "math/big" "net/rpc" "time" ) type APLClientConfig struct { Hostname string BasePort int BankHostnames []string LedgerHostname string AuditorHostname string } type BankClient interface { Audit(a *struct{}, rep *AuditRep) error Store(req *StoreArgs, _...
package controllers import ( "encoding/json" "log" "net/http" "time" "github.com/Shopify/sarama" "github.com/kafka/producer/dto" ) // ListTopic ... func ListTopic(w http.ResponseWriter, r *http.Request) { log.Println("my-cluster-kafka-bootstrap:9092") admin, err := sarama.NewClusterAdmin( []string{"my-clu...
package compliancescan import ( "context" "fmt" "github.com/go-logr/logr" "github.com/go-logr/zapr" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "go.uber.org/zap" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernete...
package controllers import ( "fmt" "net/http" "github.com/gin-gonic/gin" ) func APIEndpoints(c *gin.Context) { reqScheme := "http" if c.Request.TLS != nil { reqScheme = "https" } reqHost := c.Request.Host baseURL := fmt.Sprintf("%s://%s", reqScheme, reqHost) resources := map[string]string{ "users_url...
package game_test import ( "testing" "github.com/RaniSputnik/ok/game" ) func TestColourString(t *testing.T) { testCases := []struct { Colour game.Colour Expect string }{ {game.None, "None"}, {game.Black, "Black"}, {game.White, "White"}, {game.Colour(5), "Colour(5)"}, {game.Colour(7), "Colour(7)"}, ...
// Copyright 2021 Dataptive SAS. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to ...
package main import ( "fmt" "math/rand" "time" ) func main() { rand.Seed(time.Now().UTC().UnixNano()) c := rand.Intn(5) switch c { case 1: fmt.Println("One") case 2: fmt.Println("Two") case 3: fmt.Println("Three") case 4: fmt.Println("Four") default: fmt.Println("Five") } }
package cmd import ( "testing" "gotest.tools/assert" "gotest.tools/assert/cmp" ) type parseImagesTestCase struct { name string manifests string expected []string } func TestParseImages(t *testing.T) { testCases := []parseImagesTestCase{ { name: `Single`, manifests: ` apiVersion: apps/v1 kind: D...
package ravendb import ( "net/http" "strconv" ) type GetDatabaseNamesOperation struct { _start int _pageSize int } func NewGetDatabaseNamesOperation(_start int, _pageSize int) *GetDatabaseNamesOperation { return &GetDatabaseNamesOperation{ _start: _start, _pageSize: _pageSize, } } func (o *GetDataba...
package main import ( "Hybrid_Cluster/hcp-apiserver/converter/mappingTable" "Hybrid_Cluster/hcp-apiserver/handler" "encoding/json" "io/ioutil" "log" "net/http" "github.com/aws/aws-sdk-go/service/eks" ) func parser(w http.ResponseWriter, req *http.Request, input interface{}) { jsonDataFromHttp, err := ioutil....
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package crossdevicesettings is for OS settings management not specific to any given feature. package crossdevicesettings
package main import ( "fmt" "github.com/rjturek/go-phrase-util-non-mod/rjtphrasenonmod" ) func GetPhrase() string { return phrase1 } func main() { fmt.Println(GetPhrase()) fmt.Println(rjtphrasenonmod.GetPhrase()) }
/* Copyright The containerd 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...
package main import ( "fmt" ) // People is struct have name and age type People struct { Name string age int introduceOneSelf func() } // NewPeople will init people, and return a pointer func NewPeople(name string, age int) *People { // p1 := new(People) // p1.Name = name // p1.age = ...
package fileUtil import ( "fmt" "testing" "time" ) func TestTar(t *testing.T) { startTime := time.Now() // tarๅŽ‹็ผฉๆ–‡ไปถ dataList = append(dataList, "E:\\20180828_slg.sql") err := Tar(dataList, "E:\\tube.tar.gz") if err != nil { print(err) } err = UnTar("E:\\tube.tar.gz", "E:\\Temp") if err != nil { fmt.Pri...
package impl import ( "context" "github.com/mylxsw/adanos-alert/internal/repository" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) type SequenceRepo struct { col *mongo.Collection } func NewSequenceRepo(db *mongo.Database) repository.Seque...
package cloudformation // AWSDAXCluster_SSESpecification AWS CloudFormation Resource (AWS::DAX::Cluster.SSESpecification) // See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dax-cluster-ssespecification.html type AWSDAXCluster_SSESpecification struct { // SSEEnabled AWS CloudFormatio...
package packaging import ( "bytes" "fmt" "io" "io/ioutil" "os" "os/exec" "path/filepath" "strings" "text/template" "github.com/kolide/kit/fs" "github.com/kolide/kit/version" "github.com/pkg/errors" ) const ( // Enroll secret should be readable only by root secretPerms = 0600 ) // PackagePaths is a sim...
package game import "math/rand" type Cell struct { X, Y int } func NewCell(step Event) Cell { switch step { case Up: return Cell{0, -1} case Down: return Cell{0, 1} case Left: return Cell{-1, 0} case Right: return Cell{1, 0} } return Cell{0, 0} } type Arena struct { FromX, ToX int FromY, ToY int ...
/* * * Copyright 2020 gRPC 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 agree...
package areaManage import ( "github.com/wudiliujie/common/eventhub" "yxlserver/services/I/eventcode" "yxlserver/services/consts" "yxlserver/services/tb/tbArea" ) //ๅฐๅŒบ็ฎก็† type AreaData struct { AreaId int32 //ๅŒบ็ผ–ๅท State consts.ServerState AreaInfo *tbArea.ServerInfo } func (a *AreaData) CheckOpen() { if a...
// Copyright 2020 The gVisor 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 agree...
package ecs import ( "github.com/aliyun/alibaba-cloud-sdk-go/sdk" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" ) // Client is the ess client type Client struct { *ecs.Client } // New returns a new ess client func New(c sdk.Client) *Client { return &Client{&ecs.Client{Client: c}} }
package part_controller import ( "github.com/martini-contrib/render" "log" "net/http" ) func Search(rw http.ResponseWriter, req *http.Request, ren render.Render) { data := make(map[string]interface{}) var err error if err != nil { log.Print(err) } ren.HTML(200, "partSearch", data) } func PartTree(rw http....
package api import ( "errors" "fmt" "grpc_api/database" "grpc_api/proto" "strconv" context "golang.org/x/net/context" ) type Server struct { Database *database.Database } func (s *Server) AddUser(ctx context.Context, in *proto.AddUserRequest) (*proto.UserResponse, error) { user := &database.User{ Email: ...
package manifest import ( "encoding/json" "fmt" "net/http" "github.com/containerd/containerd/platforms" dockerDistribution "github.com/docker/distribution" dockerManifestList "github.com/docker/distribution/manifest/manifestlist" dockerSchema1 "github.com/docker/distribution/manifest/schema1" dockerSchema2 "g...
package repository import "algogrit.com/emp-server/employee/entities" // EmployeeRepository represents a employee store type EmployeeRepository interface { RetrieveAll() []entities.Employee FindBy(int) *entities.Employee Save(entities.Employee) (*entities.Employee, error) Update(int, entities.Employee) error }
package main import ( "fmt" "math/rand" ) type Game struct { Deck []Card } type Card struct { Suit string Number string } func GenerateDeck() []Card { var deck []Card suits := []string{"Heart", "Diamond", "Club", "Spade"} numbers := []string{"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"}...
// 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 arc import ( "context" "io/ioutil" "os" "github.com/golang/protobuf/ptypes/empty" "google.golang.org/grpc" "chromiumos/tast/common/perf" "chromiumos/tast/co...
package zigzag import "bytes" /* ๆŒ‰็ดขๅผ•่ง„ๅพ‹ๅค„็† p = numRows * 2 - 2 ็ฌฌ0่กŒ 0*p, 1*p ็ฌฌr่กŒ r, 1*p -r, 2*p + r ็ฌฌn่กŒ numRows - 1, numRows - 1 + p */ func ZigZagConvert(str string, numRows int) string { if numRows <= 1 || len(str) < numRows { return str } p := numRows * 2 - 2 res := bytes.Buffer{} //ๅค„็†็ฌฌไธ€่กŒ for i := 0;...
package problem0567 func checkInclusion(s1 string, s2 string) bool { window := len(s1) s1record := makeRecord(s1) for i := 0; i <= len(s2)-window; i++ { s2record := makeRecord(s2[i : i+window]) if isSame(s1record, s2record) { return true } } return false } func makeRecord(s string) []int { record := ma...
package main import ( "encoding/json" "fmt" "strings" ) type person struct { First string Last string Age int notExported int } func main() { var p1 person // creamos un lector para la string en formato JSON (normalmente seria informacion de fuera) rdr := strings.NewReader(`{"First":"J...
package main import ( kitlog "github.com/go-kit/kit/log" "github.com/gofunct/chronic/config" "log" "os" "os/user" ) var run = config.New() func init() { if err := run.Init(); err != nil { log.Println(err) os.Exit(1) } if err := run.Write(); err != nil { log.Println(err) os.Exit(1) } u, _ := user.Cu...
// Copyright 2020 The Moov Authors // Use of this source code is governed by an Apache License // license that can be found in the LICENSE file. package wire import ( "encoding/json" "strings" "unicode/utf8" ) // FIAdditionalFIToFI is the financial institution beneficiary financial institution type FIAdditionalFI...
// Copyright 2019 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package security import ( "context" "io/ioutil" "os" "path/filepath" "strings" "chromiumos/tast/common/testexec" "chromiumos/tast/errors" "chromiumos/tast/local/bun...
package lc // Time: O(n) // Keeps a running tally of the last 'k' nums and store the highest tally in 'max'. func findMaxAverage(nums []int, k int) float64 { var tally int for i := 0; i < k; i++ { tally += nums[i] } max := tally for i := k; i < len(nums); i++ { tally = tally + nums[i] - nums[i-k] if tall...
package line import ( "fmt" // "DA/4_queue/queue" ) // CountSort ่ฎกๆ•ฐๆŽ’ๅบ func CountSort(a []int, n int) { if n < 1 { return } max := a[0] for i := 1; i < n; i++ { if a[i] > max { max = a[i] } } max = max + 1 temp := make([]int, n) copy(temp, a) count := make([]int, max) for i := 0; i < n; i++ { ...
package api import ( "fmt" "fp-dynamic-elements-manager-controller/api/auth" "fp-dynamic-elements-manager-controller/api/backup" "fp-dynamic-elements-manager-controller/api/batch" "fp-dynamic-elements-manager-controller/api/docker" "fp-dynamic-elements-manager-controller/api/elements" "fp-dynamic-elements-manag...
// // Copyright (c) 2019-2021 Red Hat, Inc. // This program and the accompanying materials are made // available under the terms of the Eclipse Public License 2.0 // which is available at https://www.eclipse.org/legal/epl-2.0/ // // SPDX-License-Identifier: EPL-2.0 // // Contributors: // Red Hat, Inc. - initial API a...
// Copyright 2020 The gVisor 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 agree...
package main import "fmt" type rectangle struct { Length int Breadth int } func (r rectangle) area(a int) int { return r.Length * r.Breadth + a } func (r rectangle) IsSquare() bool { if (r.Length == r.Breadth) { return true; } else { return false; } } func (r rect...
package cmd import ( "fmt" "math/rand" "os" "time" "github.com/ivanovpetr/invasion/services/simulator" "github.com/spf13/cobra" ) const flagAliensNumber = "n" func NewSimulate() *cobra.Command { c := &cobra.Command{ Use: "simulate [path/to/map]", Short: "simulates invasion of aliens", Long: `We const...
/* Copyright 2014 Huawei Technologies Co., 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 la...
package odoo import ( "fmt" ) // WizardMultiChartsAccounts represents wizard.multi.charts.accounts model. type WizardMultiChartsAccounts struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` BankAccountCodePrefix *String `xmlrpc:"bank_account_code_prefix,omptempty"` BankAccountIds *...
package bot import ( "github.com/VG-Tech-Dojo/vg-1day-2017-05-20/shibadai/model" ) type ( // Broadcaster ใฏ1ใคใฎใƒใƒฃใƒณใƒใƒซใง่ค‡ๆ•ฐbotใ‚’ๅ‹•ใ‹ใ™ใŸใ‚ใฎใƒ˜ใƒซใƒ‘ใƒผใงใ™ // // msgInใงๅ—ใ‘ๅ–ใฃใŸmessageใ‚’botsใซ็™ป้Œฒใ•ใ‚ŒใŸๅ…จbotใซๆธกใ—ใพใ™ // // botsใธใฎ็™ป้ŒฒใฏBotInใง่กŒใ„ใพใ™ // // fields // BotIn chan *Bot // bots map[*Bot]bool // msgIn chan *model.Message Bro...
// This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT License was not distributed with this // file, you can obtain one at https://opensource.org/licenses/MIT. // // Copyright (c) DUSK NETWORK. All rights reserved. package kadcast_test import ( "bytes" "os" "runtime/pprof" "...
// SPDX-License-Identifier: ISC // Copyright (c) 2014-2021 Bitmark Inc. // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package main import ( "fmt" "github.com/bitmark-inc/bitmarkd/command/bitmark-cli/rpccalls" "github.com/urfave/cli" ) func runFullProvenance(c ...
package rethink import ( "time" ) type Order struct { ID string `gorethink:"id,omitempty"` OrderID string KartID string Entities []Entity `gorethink:"entities"` InitialAmount float64 `gorethink:"intial_amount"` FinalAmount float64 `gorethink:"final_amount"` Attendees ...
// Copyright 2015 The Cockroach 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 ag...
package main import ( "context" "fmt" "github.com/aws/aws-lambda-go/events" "github.com/aws/aws-lambda-go/lambda" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/endpoints" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3"...
package extractor import ( "testing" "github.com/slonegd/structstringer/internal/declaration" "github.com/slonegd/structstringer/internal/field" "github.com/stretchr/testify/assert" ) func Test_extractor_ExtractFields(t *testing.T) { tests := []struct { name string files []string typeName ...
package kolpa import ( "reflect" "testing" ) func TestUserAgent(t *testing.T) { k := C() for _, lang := range getLanguages() { k.SetLanguage(lang) useragent := k.UserAgent() typeOfOutput := reflect.TypeOf(useragent).Kind() if typeOfOutput != reflect.String { t.Errorf("UserAgent generation is failed fo...
package main import ( "errors" "fmt" "os" "golang.org/x/term" ) var ErrNoTerminal = errors.New("cannot read password from nonexistent terminal") type PasswordReader interface { ReadPassword() ([]byte, error) } type StdinPasswordReader struct{} func (pr StdinPasswordReader) ReadPassword() ([]byte, error) { i...
package main import "fmt" func main(){ //var flo float64 = 48.14141 //var str string = "qwetyutioioo" //fmt.Printf("%.2f %d %s",flo,int(flo),string(int(flo))) //fmt.Printf(" %s%s",str[0:3],str[3:len(str)]) a := 12 b := 5 fmt.Print("Number one \n") fmt.Printf("a=%d b=%d ๅŠ %d ๅ‡%d ไน˜%...
package main import "fmt" type Animal interface { print() } type Dog struct { name string age int } func (dog *Dog) print() { fmt.Printf("name: %s, age: %d,", dog.name, dog.age) } func main() { dog := Dog{name: "xiaobao", age: 2} dog.print() }
package antnet import "sync" type Error struct { Id uint16 Str string } func (r *Error) Error() string { return r.Str } var idErrMap = sync.Map{} var errIdMap = sync.Map{} func NewError(str string, id uint16) *Error { err := &Error{id, str} idErrMap.Store(id, err) errIdMap.Store(err, id) return err } var ...
package controls import ( "github.com/json-iterator/go" "github.com/labstack/echo/v4" "github.com/valyala/fasthttp" "regexp" "sofuny/config" "sofuny/utils" "time" ) // auth var github = config.Config().Auth.Github type AuthType struct { Type string `json:"type"` } func GetAuth(ctx echo.Context) error { var a...
package service type Rsp struct { ResultID int ResultMsg string } func (this *Rsp)SetResultId(resultId int){ this.ResultID=resultId } func (this *Rsp)SetResultMsg(resultMsg string,){ this.ResultMsg =resultMsg } func (this *Rsp)GetResultId() int{ return this.ResultID } func (this *Rsp)GetResultMsg() string{ retur...
package user import ( "fmt" "net/mail" "github.com/jrapoport/gothic/api/grpc/rpc/admin" "github.com/jrapoport/gothic/cmd/cli/root" "github.com/jrapoport/gothic/core/context" "github.com/jrapoport/gothic/models/user" "github.com/spf13/cobra" ) var roleCmd = &cobra.Command{ Use: `role [ID or EMAIL] [ROLE]`, ...
package pkg import ( "log" "os" "path/filepath" "testing" homedir "github.com/mitchellh/go-homedir" ) func TestCreateWorkArea(t *testing.T) { CreateWorkArea("/tmp") CleanupWorkArea() home, err := homedir.Dir() if err == nil { hometemp := filepath.Join(home, "tmp") _, err := os.Stat(hometemp) if os.Is...
package day15 import ( "regexp" "strconv" "adventofcode/io" ) type Ingredient struct { capacity, durability, flavor, texture, calories int } func parse(s string) Ingredient { var cp, d, f, t, cal int r := regexp.MustCompile(`^.*?(-?\d+).*?(-?\d+).*?(-?\d+).*?(-?\d+).*?(-?\d+)$`) match :=...
package autoupdater import ( "io/ioutil" "net/http" ) func download(url string) ([]byte, error) { res, err := http.Get(url) if err != nil { return nil, err } body, err := ioutil.ReadAll(res.Body) if err != nil { return nil, err } res.Body.Close() return body, nil }
package main import ( "fmt" ) func getMaxAndIndex(nums *[5]int) (int, int) { var max, index = nums[0], 0 for i := 1; i < len(nums); i++ { if nums[i] > max { index = i max = nums[i] } } return max, index } func main() { var array = [...]int {10, 3, -5, 28, 21} max, index := getMaxAndIndex(&array) fmt....
package server import ( "fmt" "net" "github.com/izikaj/iziproxy/shared" "github.com/izikaj/iziproxy/shared/names" ) // HerokuTCPServer - heroku server instance type HerokuTCPServer struct { core *Server // include default command handlers defaultTCPCommands } // Start - start HerokuTCPServer daemon func (se...
func containsPattern(arr []int, m int, k int) bool { for i := 0; i < len(arr)-m*k+1; i++ { for j := 0; j < k; j++ { if !equal(arr[i:i+m], arr[i+m*j:i+m*j+m]) { break } if j == k-1 { return true } } } return false } func equal(a, b []int) bool { for i := 0; i < len(a); i++ { if a[i] != b[i...
package requests import ( "encoding/json" "fmt" "io/ioutil" "net/url" "strings" "time" "github.com/google/go-querystring/query" "github.com/atomicjolt/canvasapi" "github.com/atomicjolt/canvasapi/models" ) // UpdateModule Update and return an existing module // https://canvas.instructure.com/doc/api/modules...
// Copyright 2017 Walter Schulze // // 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 odoo import ( "fmt" ) // MailMassMailingStage represents mail.mass_mailing.stage model. type MailMassMailingStage struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` CreateDate *Time `xmlrpc:"create_date,omptempty"` CreateUid *Many2One `xmlrpc:"create_uid,omptempty"` DisplayName *Str...
// Copyright (C) 2023 Storj Labs, Inc. // See LICENSE for copying information. package storj import ( "fmt" "net/url" "storj.io/common/base58" ) // NoiseProto represents different possible Noise handshake and cipher suite // selections. type NoiseProto int const ( // NoiseProto_Unset is an unset protocol. Noi...
package host import ( "fmt" "io" "os" "path" "time" ) // BackupFile creates a copy of your hosts file to a new location with the date as extension func BackupFile(src, dstPath string) (string, error) { srcFile, err := os.Open(src) if err != nil { return "", err } defer srcFile.Close() bkpFilename := getB...
package controller import ( "MicroNet.LogCollect/common" "MicroNet.LogCollect/models" "github.com/gin-gonic/gin" "log" "net/http" "time" ) func GetLogRecord(c *gin.Context) { c.JSON(http.StatusOK, models.LogModel{Id:"1",System:"ๆต‹่ฏ•็ณป็ปŸ",Module:"ๆต‹่ฏ•ๆจกๅ—",FuncName:"ๆต‹่ฏ•ๆ–นๆณ•", FuncParameter:"ๆต‹่ฏ•ๅ‚ๆ•ฐ",Lo...
// 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 hamt import ( "bytes" "context" "fmt" "testing" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" cbor "github.com/ipfs/go-ipld-cbor" ) func TestRoundtrip(t *testing.T) { ctx := context.Background() cs := NewCborStore() n := NewNode(cs) n.Bitfield.SetBit(n.Bitfield, 5, 1) n...
package main import ( "bufio" "fmt" "os" "regexp" "strconv" "strings" ) const ( rowLength = 9 minArgsCount = 2 ) type Board [9][9]int func NewBoard(b [9][9]int) *Board { board := Board(b) return &board } func (b *Board) Solve() bool { if !b.hasEmptyCell() { return true } for i := 0; i < 9; i++ { ...
package daterange import ( "time" "github.com/TIBCOSoftware/flogo-lib/core/activity" "github.com/TIBCOSoftware/flogo-lib/logger" ) // ActivityLog is the default logger for the Log Activity var activityLog = logger.GetLogger("activity-flogo-parsecsv") const ( ivFormat = "format" ivStartDate = "startDate" iv...
package service import ( "encoding/json" "log" "github.com/jelinden/stock-portfolio/app/domain" "github.com/jelinden/stock-portfolio/app/util" ) func GetPortfolioNews(query string) domain.News { news := util.Get(`https://www.uutispuro.fi/api/news?q=`+query, 60) var marshalled domain.News err := json.Unmarshal...
/** * gomserver main.go */ package main import ( "base" "encoding/binary" "flag" "fmt" "os" //"os/exec" //"handle" "io" "log" "net" "path/filepath" ) const ( TGW_HEADER_SIZE = 1024 * 4 TGW_HEADER_SEG_COUNT = 3 ) func main() { //ๅฎˆๆŠค่ฟ›็จ‹๏ผŒๅผ€ๅง‹ d := flag.Bool("d", false, "Whether or not to launch in the...
package main /* --- Day 8: Memory Maneuver --- The sleigh is much easier to pull than you'd expect for something its weight. Unfortunately, neither you nor the Elves know which way the North Pole is from here. You check your wrist device for anything that might help. It seems to have some kind of navigation system! A...