text
stringlengths
11
4.05M
package main import ( "fmt" "math" "github.com/jackytck/projecteuler/tools" ) // Smallest positive number that is divisible by all of the numbers from 1 to n. func lcm(n int) int { lcm := make(map[int]int) for i := 2; i <= n; i++ { for k, v := range tools.PrimeFactors(i) { if v > lcm[k] { lcm[k] = v ...
// Copyright 2023-2023 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...
package api_server import ( "time" "github.com/emicklei/go-restful" "github.com/kumahq/kuma/pkg/core" "github.com/kumahq/kuma/pkg/core/resources/access" "github.com/kumahq/kuma/pkg/core/resources/apis/mesh" "github.com/kumahq/kuma/pkg/core/resources/apis/system" "github.com/kumahq/kuma/pkg/core/resources/mana...
package service import ( "bytes" "fmt" "gin-vue-admin/global" "gin-vue-admin/model" "gin-vue-admin/model/request" ) // @title CreateTitTrainingInfo // @description create a TitTrainingInfo // @param trainingInfo model.TitTrainingInfo // @auth weiqin // @return err error...
package linijka import ( "fmt" "io" "log" "strings" "golang.org/x/text/encoding/charmap" ) func encodeWindows1250(inp string) string { enc := charmap.Windows1250.NewEncoder() out, _ := enc.String(inp) return out } func tobytes(inp string) []byte { return []byte(encodeWindows1250(inp)) } func sumxor(text [...
package serializer import ( "fmt" "github.com/allentom/youcomic-api/model" "github.com/allentom/youcomic-api/services" "github.com/jinzhu/copier" "path" "strconv" "time" ) type BaseBookTemplate struct { ID uint `json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"...
package main import "fmt" func main() { grades := make(map[string]float64) grades["Timmy"] = 42 grades["Jessica"] = 92 grades["Matt"] = 70 fmt.Println(grades) //TimsGrade := grades["Timmy"] delete(grades, "Timmy") //fmt.Println(TimsGrade) fmt.Println(grades) for k,v := range grades { fmt.Println(k, v)...
package helper import "fmt" func SayHello() { fmt.Printf("Hai danil syah") } // func person() { // fmt.Println("kenalkan") // }
package main import ( "sync" ) const ( diffStatusCodeError = "diff-status-code" errorUnmarshalLeftError = "error-unmarshal-left" errorUnmarshalRightError = "error-unmarshal-right" ok = "ok" ) type Consumer struct { Exclude []string } func NewConsumer() *Consumer { return &Consumer...
// Copyright (c) 2019 Tailscale Inc & AUTHORS All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package atomicfile contains code related to writing to filesystems // atomically. // // This package should be considered internal; its API is no...
package vgform import "github.com/vugu/vugu" // Textarea corresponds to a textarea HTML element. type Textarea struct { Value StringValuer // get/set the currently selected value AttrMap vugu.AttrMap } func (c *Textarea) handleChange(event vugu.DOMEvent) { newVal := event.PropString("target", "value") // c.cu...
package version import ( "errors" "fmt" "os" "regexp" "sort" "strings" ) var ( // Version stores the version of the current build (e.g. 2.0.0) Version = "dev" // PreReleaseIdentifier stores the pre-release identifier of the current build (eg. beta-2) PreReleaseIdentifier string // BuildDate stores the ti...
package util import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" ) // CreateServiceAccountWithToken creates a service account with a given name with a service account token. // Need to use this function to simulate the actual behavior of Kubernetes API s...
package main import ( "context" "errors" "fmt" "golang.org/x/sync/errgroup" "os" "os/signal" "syscall" ) func main() { ctx, cancel := context.WithCancel(context.Background()) defer cancel() eg, ctx := errgroup.WithContext(context.Background()) // 基于 errgroup 实现一个 http server 的启动和关闭 ,以及 linux signal 信号的注册和...
package files import ( "github.com/therecipe/qt/core" "github.com/therecipe/qt/quick" "github.com/therecipe/qt/internal/examples/showcases/wallet/files/controller" "github.com/therecipe/qt/internal/examples/showcases/wallet/files/dialog" ) func init() { filesTemplate_QmlRegisterType2("FilesTemplate", 1...
package main import ( "fmt" "path" "strings" "github.com/go-ini/ini" "github.com/kjbreil/sil" "github.com/kjbreil/sil/loc" "github.com/manifoldco/promptui" ) func gui() (err error) { // declare the CFG table type cfg := loc.CFG{ F1000: "999901", F1056: "999", F2846: "GROC_LANE", F253: sil.JulianNow...
package multiclient import ( "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address" "github.com/iotaledger/wasp/client" "github.com/iotaledger/wasp/packages/webapi/model" ) // DKSharesGet retrieves distributed key info with specific ChainID from multiple hosts. func (m *MultiClient) DKSharesGet(sh...
package discovery import ( "sync" "github.com/youtube/vitess/go/sync2" "github.com/youtube/vitess/go/vt/tabletserver/sandboxconn" "github.com/youtube/vitess/go/vt/tabletserver/tabletconn" "github.com/youtube/vitess/go/vt/topo" querypb "github.com/youtube/vitess/go/vt/proto/query" topodatapb "github.com/youtub...
// Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 package chainimpl import ( "bytes" "github.com/iotaledger/wasp/packages/chain" "github.com/iotaledger/wasp/packages/peering" ) func (c *chainObj) dispatchMessage(msg interface{}) { if !c.isOpenQueue.Load() { return } switch msgt := msg....
package main import ( "net/http" "fmt" ) type String string func (s String) ServeHTTP(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, s) } type Struct struct { A string B string C string } func (s Struct) ServeHTTP(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, s) } func ma...
package display import ( "github.com/GoAdminGroup/go-admin/template/icon" "github.com/GoAdminGroup/go-admin/template/types" ) type Icon struct { types.BaseDisplayFnGenerator } func init() { types.RegisterDisplayFnGenerator("icon", new(Icon)) } func (i *Icon) Get(args ...interface{}) types.FieldFilterFn { retur...
/* Copyright 2023 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 hydrasdk import ( "crypto/rsa" "net/http" "net/url" "github.com/juju/errors" jose "github.com/square/go-jose" ) // KeyGetter provides functions to retrieve a key from an hydra set (tipically the first) type KeyGetter interface { GetRSAPublic(set string) (*rsa.PublicKey, error) GetRSAPrivate(set string...
package keycloak import ( "fmt" ) // https://www.keycloak.org/docs-api/8.0/rest-api/index.html#_authenticatorconfigrepresentation type AuthenticationExecutionConfig struct { RealmId string `json:"-"` ExecutionId string `json:"-"` Id string `json:"id"` Alias str...
package efclient import ( "bytes" "encoding/json" "fmt" "log" "net/http" "sync" "time" "syreclabs.com/go/faker" "syreclabs.com/go/faker/locales" ) // Label ... type Label struct { ID int `json:"id"` } // LabelData ... type LabelData struct { Title string `json:"title"` Description string `json:"de...
/* Copyright (C) 2018 Black Duck Software, Inc. Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version...
/* * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. * Licensed under the MIT License (the "License"); you may not use this file except * in compliance with the License. You may obta...
package test import ( "fmt" "gengine/engine" "testing" "time" ) const rp1 = ` rule "1" "1" begin sleep() println("hello") end ` const rp2 = ` rule "1" "1" begin sleep() println() end rule "2" "2" begin sleep() println() end ` func SleepTime() { //println("睡觉") //time.Sleep(100 * time.Second ) } func Test_rp1...
package main import ( "log" "math/rand" "time" ) type Response string func init() { rand.Seed(time.Now().UnixNano()) } func main() { GetAllTheThings([]string{"one", "two", "three", "four", "five"}) } func GetTheThing(url string) Response { time.Sleep(time.Duration(rand.Int()%1000) * time.Millisecond) return...
// Copyright 2019 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 configs import ( "fmt" "log" "os" "os/exec" "reflect" "strings" "github.com/gabrie30/ghorg/colorlog" "github.com/mitchellh/go-homedir" "github.com/spf13/viper" ) func init() { initConfig() } func initConfig() { viper.SetConfigType("yaml") viper.AddConfigPath(ghorgDir()) viper.SetConfigName("co...
package filter import ( "testing" ) func TestLabelMatchEq(t *testing.T) { var tests = []struct { match *LabelMatchEq labels map[string]string ans bool ans2 bool }{ { &LabelMatchEq{"a", "b"}, map[string]string{"a": "b"}, true, true, }, { &LabelMatchEq{"a", "b"}, map[string]stri...
package utils import ( "errors" "gopkg.in/mgo.v2/bson" ) var ( ErrInvalidObjectId = errors.New("Invalid ObjectID format") ) func IsObjectId(id string) bool { return bson.IsObjectIdHex(id) } //Function will take types string or bson.ObjectId represented by a type interface{} and returns //a type bson.ObjectId. ...
package font import ( "crypto/md5" "sync" "github.com/gop9/olt/gio/font/opentype" "github.com/gop9/olt/gio/text" "github.com/gop9/olt/gio/unit" "golang.org/x/image/font" "golang.org/x/image/math/fixed" ) type Face struct { fnt *opentype.Font shaper *text.Shaper size int fsize fixed.Int26_6 met...
package template import ( "html/template" "io/ioutil" "github.com/MihaiBlebea/dog-ceo/dog" ) type service struct { dogService dog.Service } // New returns a new template service func New(dogService dog.Service) Service { return &service{dogService} } func (s *service) Load(path string) (*Page, error) { b, er...
package backend import ( "context" "encoding/json" "fmt" "log" "math/rand" "net/http" "sync" "time" ) // The following message types are for communication by channels. // messageIndex announces their own position on the board. type messageIndex struct { Index int `json:"index"` } func (messageIndex) IsMess...
package commands import ( // HOFSTADTER_START import // HOFSTADTER_END import // custom imports // infered imports "github.com/spf13/cobra" "github.com/hofstadter-io/examples/blog/server/tools/db-ops/commands/user" ) // Tool: serverToolDB // Name: user // Usage: // Parent: serverToolDB // HOFSTADTER_...
package model //{"user_email":"niconicocsc@gmail.com","roles":["user"],"iat":1609415731,"exp":1609416631,"jti":"e3582954-6b17-4ef2-9bdf-0274da1033f3","iss":"Gnemes"} type PlayLoad struct { UserEmail string }
/* Copyright 2015 Crunchy Data Solutions, 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 parser import ( "fmt" "golang.org/x/net/html" "io" "strings" ) var links []*Link func ParseLinks(r io.Reader) []*Link { l := &links node, err := html.Parse(r) if err != nil { fmt.Println(err) } crawl(node, l) return links } func crawl(n *html.Node, l *[]*Link) { checkForATypes(n, l) if n.NextS...
package mockexample import "github.com/cyongxue/magicbox/mockexample/spider" func GetGoVersion(s spider.Spider) string { body := s.GetBody() return body }
// Package osbuild provides primitives for representing and (un)marshalling // OSBuild types. package osbuild2 import ( "testing" "github.com/stretchr/testify/assert" ) func TestPipeline_AddStage(t *testing.T) { expectedPipeline := &Pipeline{ Build: "name:build", Stages: []*Stage{ { Type: "org.osbuild....
// Package reader - save read record package reader
package gauth import ( "testing" ) func TestTOTP(t *testing.T) { secret := "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" timeIntervals := int64(47156746) correctOTP := "109431" otp, err := computeTOTP(secret, timeIntervals) if err != nil { t.Errorf("computeTOTP returns an error for valid input: %s", err.Error()) } if ...
package terminfo import ( "errors" "fmt" "strings" ) // GetBuiltin returns a named builtin Terminfo. func GetBuiltin(term string) (*Terminfo, error) { if term == "" { if defaultTerm == "" { return nil, errors.New("no term name given, and no default defined") } term = defaultTerm } if ti, def := builtin...
package post import "github.com/alejogs4/blog/src/post/domain/like" type PostRepository interface { CreatePost(post Post) error AddLike(postID string, like like.Like) error RemoveLike(like like.Like) error AddComment(comment Comment) error RemoveComment(comment Comment) error GetPostCommentByID(id string) (Com...
package antlr // Represents the type of recognizer an ATN applies to. const ( ATNTypeLexer = 0 ATNTypeParser = 1 )
// Package main defines the nectar command line tool. package main import ( "os" "github.com/troubling/nectar" ) func main() { nectar.CLI(os.Args, nil, nil, nil) }
package register import ( "crypto/md5" "fmt" "io" "log" "net/http" "github.com/hieutm211/basicweb/config" "github.com/hieutm211/basicweb/register/regfunc" ) func Handler(w http.ResponseWriter, r *http.Request) { var err error username := r.FormValue("username") pw := md5.New() io.WriteString(pw, r.FormVa...
package main import "fmt" func main2301() { s := []int{1,2,3,4,5} //指针和切片建立联系 p := &s fmt.Printf("%p\n",p) fmt.Printf("%p\n",s) //*[]int //var p *[]int fmt.Printf("%T\n",p) //通过指针间接操作切片元素 //p[1] = 222 (*p)[1] = 222 fmt.Println(s) //for循环遍历 for i:=0;i<len(s) ; i++ { fmt.Println((*p)[i]) } } //切片指针...
package processing import ( "fmt" "regexp" "strconv" "time" "github.com/pkg/errors" ) // Logsync Interfface to use for uploading to different services type Logsync interface { Process(bool) error } // FileMatch is used to keep track of path, matched strings, and rotated Time type FileMatch struct { path ...
package admin_test import ( "context" "testing" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" kuma_cp "github.com/kumahq/kuma/pkg/config/app/kuma-cp" core_mesh "github.com/kumahq/kuma/pkg/core/resources/apis/mesh" "github.com/kumahq/kuma/pkg/core/resources/model" core_store "github.com/kumahq/kuma/pk...
package main import ( "fmt" "os" "strings" "time" ) func main() { start := time.Now() fmt.Println(strings.Join(os.Args, " ")) taken := time.Since(start).Seconds() fmt.Printf("%.8f Seconds\n", taken) }
package app import ( "fmt" "net/http" "github.com/devit-tel/goerror/ginresp" "github.com/devit-tel/gogo-blueprint/app/inout/staff" serviceStaff "github.com/devit-tel/gogo-blueprint/service/staff" "github.com/gin-gonic/gin" ) func (app *App) GetStaffsByCompany(c *gin.Context) { input := &staff.GetStaffsByCompa...
package main import ( "fmt" ) func main() { // ชุดข้อความ firstname := "Artitaya " lastname := "Yaemjaraen" sum := firstname + lastname fmt.Println(sum) // เข้าถึงข้อมูล fmt.Println(sum[1:3]) // ผลลัพธ์ rt = [1:3] }
package planets import "context" type RemovePlanetHandler struct { repository Repository } func NewRemovePlanetHandler(repository Repository) RemovePlanetHandler { return RemovePlanetHandler{ repository: repository, } } func (h RemovePlanetHandler) Execute(ctx context.Context, id interface{}) error { err := h...
package main import "fmt" // Channels are the pipes that connect concurrent func main() { messages := make(chan string) // new channel - channels are typed go func() { messages <- "ping" }() // send value into channel using <- // <- channel syntax receives value from the channel msg := <-messages fmt.Println(...
package file_common import "errors" type fileFormat int const ( IMAGE = fileFormat(1) VIDEO = fileFormat(2) AUDIO = fileFormat(3) GIF = fileFormat(4) ) var ErrBadReq = errors.New("bad request") var ErrWrongFileName = errors.New("wrong file name") var ErrFileNameTooShort = errors.New("file name too short") va...
package memcache import ( "bufio" "bytes" "errors" "io" "io/ioutil" "log" "net" "sync" "time" ) var ( ErrCacheMiss = errors.New("memcache.Client: cache miss") ErrCasidMismatch = errors.New("memcache.Client: casid mismatch") ErrClientNotRunning = errors.New("memcache.Client: the clien...
package main import ( "log" "time" _ "github.com/lib/pq" "github.com/yulyulyharuka/todo2/model" "github.com/yulyulyharuka/todo2/storage" ) // type Customer struct { // ID int // Name string // Address string // Phone string // Birthdate string // } func main() { // initiate var memStor...
package problem0188 import "testing" func TestMaxProfit(t *testing.T) { t.Log(maxProfit(2, []int{3, 2, 6, 5, 0, 3})) }
/* 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...
// Copyright 2019 Authors of Cilium // // 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 ( "database/sql" "fmt" _ "github.com/lib/pq" "log" "net/http" "os" ) func HelloWorld(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Hello World!\n")) fmt.Fprintf(w, "os.Args: %#v\n", os.Args) dburl := fmt.Sprintf("%s://%s:%s@%s:%s/%s", os.Getenv("DB_ENGINE"), os.Getenv("DB_US...
// Copyright 2023 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applica...
package base import ( "sort" "strconv" "time" ) const ( _ int = iota Buy_tick Sell_tick Eq_tick ) type Tick struct { Time time.Time Price int Change int Volume int // 手 Turnover int // 元 Type int } type RealtimeTick struct { Tick HL Buyone int Sellone int Status int Name strin...
package linereader import ( "bufio" "fmt" "io" "strings" ) type srcError struct { file string line int snippet string msg string } func (e *srcError) Error() string { return fmt.Sprintf("%s:%d: error: %s\nin:\n%s", e.file, e.line, e.msg, e.snippet) } // LineReader read text stream line by line ty...
package hermes import ( "encoding/base64" "errors" "fmt" "math/rand" "sync/atomic" "time" "golang.org/x/net/context" "golang.org/x/sync/errgroup" "gopkg.in/olivere/elastic.v5" ) var ( // ErrNilHostParameter defines you cannot have a nil elasticsearch host address ErrNilHostParameter = errors.New("missing ...
package storage import ( "time" "github.com/Tanibox/tania-core/src/tasks/domain" "github.com/gofrs/uuid" ) type TaskEvent struct { TaskUID uuid.UUID Version int CreatedDate time.Time Event interface{} } type TaskRead struct { Title string `json:"title"` UID uuid.U...
package kucoin import ( "crypto/tls" "encoding/json" "fmt" "math/rand" "net/http" "net/url" "sync" "time" "github.com/gorilla/websocket" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) // A WebSocketTokenModel contains a token and some servers for WebSocket feed. type WebSocketTokenModel struct { ...
package summary import ( "testing" "time" "github.com/stretchr/testify/assert" ) func TestSummaryMinInterval(t *testing.T) { count := New(time.Second/2, 10) tk1 := time.NewTicker(5 * time.Millisecond) defer tk1.Stop() for i := 0; i < 100; i++ { <-tk1.C count.Add(2) } v, c := count.Value() t.Logf("coun...
package utils import ( "time" "context" "strings" "github.com/satori/go.uuid" ) var reqID struct{} var reqStartTime struct{} // SetReqID : 设置一个reqID func SetReqID(ctx context.Context) context.Context { uid:= uuid.NewV4() str := strings.Replace(uid.String(), "-", "", -1) c := context.WithValue(ctx, reqID, s...
package cacheutil import ( "sync" ) //Queue ... type Queue struct { hashMap map[uint64]*sync.WaitGroup mux sync.RWMutex } //NewQueue ... func NewQueue() *Queue { return &Queue{ hashMap: make(map[uint64]*sync.WaitGroup), } } //Set ... func (q *Queue) Set(hashedKey uint64) bool { q.mux.Lock() defer q.mux...
package utils import ( "time" md "github.com/ebikode/eLearning-core/model" "github.com/uniplaces/carbon" "golang.org/x/crypto/bcrypt" ) // ValidatePincode - validates a user pincode func ValidatePincode(user *md.User, pincode string) bool { if user == nil || user.Pincode == "" || user.IsPincodeUsed { return f...
package main import ( "encoding/json" "fmt" "io/ioutil" "math/rand" "net/http" "os" "reflect" "strconv" "time" "github.com/therecipe/qt/core" "github.com/therecipe/qt/gui" "github.com/therecipe/qt/widgets" ) var data_struct struct { Month string `json:"month"` Num int ...
package main import "fmt" func main() { //如果参与除法运算的都是整数,计算后去掉小数部分,留下整数,下面结果是2,不是2.5 fmt.Println(10 / 4) var num float64 = 10 / 4 fmt.Println(num) //如果希望保留小数部分,除法运算里面要有一个是小数 fmt.Println(10.0 / 4) //取模运算 //a % b = a - a / b * b fmt.Println(10 % 3) fmt.Println(-10 % 3) // -10 - (-10) / 3 * 3 = -10 - (-9) = -1 ...
package types type Neo4jQueryResponse struct { Results []Neo4jQueryResult `json:"results"` Errors []Neo4jQueryErr `json:"errors"` } type Neo4jQueryResult struct { Columns []string `json:"columns"` DataArr []Neo4jQueryResultData `json:"data"` } type Neo4jQueryErr struct { Code string `json:"...
package db import ( "testing" ) var ds *DataSource func initMysql() { mysqlconfig := &MysqlConfig{ MysqlAddr: "localhost", MysqlPort: "3306", MysqlUser: "root", MysqlPassword: "12345678", MysqlDB: "test111", } } type User struct { Name string Age int } func TestExec(t *testing.T) ...
package yai import ( "fmt" "io" "net/http" "os" "path/filepath" "strings" "sync" multierror "github.com/hashicorp/go-multierror" "github.com/pkg/errors" ) // Installer installs the app according the contained manifest. type Installer struct { DownloadTo string InstallTo string Shim Shim Manifest ...
package gov import ( "fmt" "github.com/irisnet/irishub/app/v1/params" "github.com/irisnet/irishub/codec" sdk "github.com/irisnet/irishub/types" "strconv" "time" ) const ( CRITICAL_DEPOSIT = 4000 IMPORTANT_DEPOSIT = 2000 NORMAL_DEPOSIT = 1000 CRITICAL = "Critical" IMPORTANT ...
// +build mom_log package main import ( "fmt" "io" "net" "os" ) func main() { // fmt.Println(string(line)) // conn, err := net.Dial("tcp", ":"+*port) conn, err := net.Dial("tcp", ":1774") if err != nil { panic(err) } defer conn.Close() cmd := os.Args[1] for i := 2; i < len(os.Args); i++ { arg := [...
package sort // ShellSort 希尔排序 // 参考插入排序 InsertionSort,但是事先分了多组序列并在同一趟进行插入排序 func ShellSort(arr *[]int, scale int) { // arr拆分为step个数组 // 每一轮的第n个数组arr_n = // (arr[n-1], arr[n-1 + step], ..., arr[i + (n-1) * step]) for step := len(*arr) / scale; step > 0; step /= scale { // 每一轮减少step,直到step == 1 ...
package composer import ( "log" "encoding/json" ) func JsonStringToComposerJson(jsonString []byte) (ComposerJson) { var composerJson ComposerJson err := json.Unmarshal(jsonString, &composerJson) if err != nil { log.Fatalln("Unable to convert json string to struct:", err) } return composerJson }
package shader import ( "image" "image/draw" _ "image/jpeg" _ "image/png" wrapper "github.com/akosgarai/opengl_playground/pkg/glwrapper" "github.com/go-gl/mathgl/mgl32" ) type Shader struct { shaderProgramId uint32 textures []texture directionalLightSources []DirectionalLightSource p...
package main import "fmt" func main(){ switch { case (true && true): fmt.Println("migliorare in go") case (true && false): fmt.Println("procrastinare") case (true || true): fmt.Println("migliorare in python") case (true || false): fmt.Println("rimandare") case (!true): fmt.Println("studiare pentesting...
package main import ( "fmt" "strconv" log "github.com/sirupsen/logrus" "texas_real_foods/pkg/timeseries-analyser" "texas_real_foods/pkg/utils" ) var ( // create map to house environment variables cfg = utils.NewConfigMapWithValues( map[string]string{ "postgres_url": "postgres://p...
package types type TxResponse struct { Jsonrpc string `json:"jsonrpc"` Result TxResult `json:"result"` ID int `json:"id"` } type TxStatus struct { Ok interface{} `json:"Ok"` } type TxMeta struct { Err interface{} `json:"err"` Fee int `json:"fee"` InnerInstru...
package ifelse //func If(ok bool, a, b int) int func AsmIf(ok bool, a, b int) int
package main import ( "sync" ) // manager holds jobs type manager struct { sync.RWMutex jobs map[string]*Job } // Manager is the entry point to jobs var Manager = manager{jobs: make(map[string]*Job)} func (man *manager) addJob(job *Job) { man.Lock() defer man.Unlock() man.jobs[job.ID] = job } func (man *mana...
// 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 routers import ( "github.com/astaxie/beego" "test_proj/chatRoom/controllers" ) func init() { beego.Router("/", &controllers.MainController{}) beego.Router("/chatRoom", &controllers.ServerController{}) beego.Router("/logout", &controllers.ServerController{}, "get:Logout") beego.Router("/upload", &control...
package main import ( "fmt" "path/filepath" "github.com/jraams/aoc-2020/helpers" ) func main() { // Load input from file inputPath, _ := filepath.Abs("input") inputValues := helpers.GetInputValues(inputPath) gameconsole := loadInstructions(inputValues) // Part 1 _, accumulator := runInstructions(gameconsol...
package baby import ( "github.com/babyboy/leveldb" "github.com/babyboy/log" "github.com/babyboy/node" "github.com/babyboy/p2p" "github.com/babyboy/p2p/nat" ) type Node struct { node *node.Node } func NewNode(dataDir string) (stack *Node, _ error) { cfg := babyboy.BabyConfig{ Node: node.Config{ DataDir: ...
package entity import ( "github.com/mirzaakhena/danarisan/application/apperror" "github.com/mirzaakhena/danarisan/domain/vo" "time" ) type Arah string const ( ArahBertambah = "BERTAMBAH" ArahBerkurang = "BERKURANG" ) type SaldoAkun struct { BaseModel ArisanID vo.ArisanID `json:"-"` // PesertaID vo.Peserta...
package server import ( "context" "encoding/json" "fmt" "strconv" "github.com/thedevsaddam/gojsonq" "github.com/volatiletech/sqlboiler/boil" . "github.com/volatiletech/sqlboiler/queries/qm" "golang.org/x/crypto/bcrypt" "orm/models" "orm/ormpb" ) const BcryptCost = 12 func (s *UserBoilerOrm) ById(ctx con...
package auth import ( "fmt" "log" "net/http" "github.com/gorilla/sessions" ) var ( sessionStore = createStore() ) const ( // DefaultSessionName is a default name for the cookie which store session. DefaultSessionName = "chlorine_session" ) // Session is a structure for creating handlers with session. type S...
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. package azurestack import ( "bytes" "context" "github.com/Azure/aks-engine/pkg/armhelpers" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage" azStorage "github.com/Azure/azure-sdk-for-go/sto...
package controllers import ( "net/http" "strconv" "example.com/banking/datalib" "example.com/banking/helpers" "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" ) var Logger *logrus.Entry func GetBalance(c *gin.Context) { id, err := strconv.Atoi(c.Param("id")) if err != nil { c.JSON(...
package main import ( "encoding/json" "net/http" "net/http/httptest" "net/url" "path/filepath" "strings" "testing" "time" "github.com/gin-gonic/gin" "github.com/teris-io/shortid" "gopkg.in/mgo.v2/bson" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" "urlshortener.api/models" u...
/* * @lc app=leetcode.cn id=1880 lang=golang * * [1880] 检查某单词是否等于两单词之和 */ // @lc code=start // package leetcode func stoi(word string) int { ret := 0 for i := 0; i < len(word); i++ { ret += int(word[i] - 'a') ret *= 10 } return ret } func isSumEqual(firstWord string, secondWord string, targetWord string)...