text
stringlengths
11
4.05M
package main import ( _ "github.com/go-sql-driver/mysql" "context" "github.com/moyrne/tebot/configs" "github.com/moyrne/tebot/internal/analyze" "github.com/moyrne/tebot/internal/database" "github.com/moyrne/tebot/internal/logs" "github.com/moyrne/tebot/internal/service/api" "github.com/moyrne/tebot/internal/s...
package _670_Maximum_Swap import ( "math" ) func maximumSwap(num int) int { var ( currMax int maxPos int pos1, pos2 int l = []int{} ret int ) for i := 0; num != 0; i++ { n := num % 10 l = append(l, n) if n > currMax { currMax = n maxPos = i } if n < currMax { po...
package daos import ( "github.com/google/uuid" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/sqlite" "github.com/go-gnss/data/cmd/database/models" ) func GetObservation(id uuid.UUID) (*models.Observation, error) { // This should be in config package db, err := gorm.Open("sqlite3", "../test.db") i...
package emulator type ConditionCodes struct { z uint8 s uint8 p uint8 cy uint8 ac uint8 pad uint8 //uint8_t z:1 //uint8_t s:1; //uint8_t p:1; //uint8_t cy:1; //uint8_t ac:1; //uint8_t pad:3; } type State8080 struct { a uint8 b uint8 c uint8 d ...
package main import ( "fmt" "sync" ) func main() { var wg sync.WaitGroup wg.Add(2) go fun1(&wg) go fun2(&wg) fmt.Println("开始等待") wg.Wait() fmt.Println("解除阻塞") } func fun1(wg *sync.WaitGroup) { for i := 0; i < 1000; i++ { fmt.Println("[---func1----", i) } wg.Done() } func fun2(wg *sync.WaitGroup) { d...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2021/5/29 4:53 下午 # @File : linked_list_cycle_ii.go # @Description : 给定一个链表,返回链表开始入环的第一个节点。如果链表无环,则返回null。 为了表示给定链表中的环, 我们使用整数 pos 来表示链表尾连接到链表中的位置(索引从 0 开始)。 如果 pos 是 -1,则在该链表中没有环。注意,pos 仅仅是用于标识环的情况,并不会作为参数传递到函数中。 说明:不允许修改给定的链表。 进阶: 你是否可以使用 O(1) 空间解决此题? # @Att...
/* * @lc app=leetcode.cn id=1460 lang=golang * * [1460] 通过翻转子数组使两个数组相等 */ // @lc code=start package main func canBeEqual(target []int, arr []int) bool { count := make(map[int]int) for i := 0; i < len(target); i++ { count[target[i]] += 1 } for i := 0; i < len(arr); i++ { count[arr[i]] -= 1 if count[arr[i...
package main import "fmt" type Node struct { next *Node val int } func main() { //처음 root의 노드 var root *Node root = &Node{nil, 0} //Node.next에 nil이 있는 node를 가리키는 것을 tail 노드 var tail *Node tail = root var want_end int fmt.Print("몇 번째까지 추가를 원하나요? : ") fmt.Scanf("%d", &want_end) for i := 1; i <= want_e...
package cache import ( "encoding/json" "errors" "fmt" "io/ioutil" "net/http" "os" "testing" "time" redis "gopkg.in/redis.v3" "github.com/kataras/iris" // you could use that library now to do http testing: "github.com/kataras/iris/httptest" ) const ( irisSrvWithMemoryStore = "127.0.0.1:1234" irisSrvWith...
package c43_dsa_from_nonce import ( "bytes" "crypto/sha1" "math/big" "testing" "github.com/vodafon/cryptopals/set1/c1_hex_to_base64" ) func TestSing(t *testing.T) { dsa := NewDSA() msg := []byte("Some text") r, s := dsa.Sign(msg) ver := dsa.Verify(msg, r, s) if !ver { t.Errorf("Incorrect result. Expected...
package main func SockMerchant(n int, socks []int) int { maxIndex := getMax(socks, n) helper := make([]int, maxIndex+1) for _, sock := range socks { helper[sock]++ } var sum int for _, help := range helper { sum += help / 2 } return sum } func getMax(slice []int, length int) int { max := 0 for i := 0; i...
package v3 import ( "bytes" "encoding/json" "errors" "fmt" "io/ioutil" "mime/multipart" "net/http" "net/url" "os" "strings" ) type ImgurClient struct { ClientId string ClientSecret string AccessToken string ExpiresIn int64 TokenType string RefreshToken string AccountUsern...
package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" "os" "text/template" ) type chapter struct { Title string `json:"title"` Story []string `json:"story"` Options []option `json:"options"` } type option struct { Text string `json:"text"` Arc string `json:"arc"` } type storyHandler s...
package forms // Type of map to hold validation error messages for form fields. // Map that maps a field name to the slice of error messages. // There might be multiple errors for a single field: length limit, blank, etc type errors map[string][]string // Add method to add error message for a given field. func (e err...
package main import ( "errors" "fmt" "os" "flag" "strings" ) const ( DEFAULT_SESSION_TOKEN_DURATION = int64(60 * 60) DEFAULT_AWS_REGION = "eu-central-1" DEFAULT_ONELOGIN_REGION = "us" ) func dieOnError(err error, message string) { if err != nil { fmt.Fprintf(os.Stderr, "%s: %v\n", message, err) os.Exit(...
package logServer import ( "bytes" "fmt" "os" "path/filepath" "strings" "time" ) // LogWriter is a structure to handle with file type LogWriter struct { logFileName string logFileDir string writeBuffer bytes.Buffer } // SetPath will set dir and file name func (w *LogWriter) SetPath(dir, fileName string) { ...
package twitter import ( "log" "strings" "github.com/kyokomi/slackbot/plugins" ) type plugin struct { accessToken string } func (r plugin) CheckMessage(_ plugins.BotEvent, message string) (bool, string) { return strings.Contains(message, "いーすん画像"), message } func (r plugin) DoAction(event plugins.BotEvent, me...
package printer import ( "strings" "github.com/davyxu/tabtoy/v2/i18n" "github.com/davyxu/tabtoy/v2/model" ) type TableIndex struct { Index *model.FieldDescriptor // 表头里的索引 Row *model.FieldDescriptor // 索引的数据 } type Globals struct { Version string InputFileList []interface{} ParaMode ...
package handler import ( "net/http" "newfeed/flatform/newfeed" "github.com/gin-gonic/gin" ) func NewFeedGet(feed *newfeed.Repo) gin.HandlerFunc { return func(c *gin.Context) { results := feed.GetAll() c.JSON(http.StatusOK, results) } }
// Copyright (C) 2019 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package code import ( "go/ast" "strconv" ) // Creates a root scope object func RootScope() *Scope { var s *Scope return s.New() } // Scope tracks all used ...
package main import ( "fmt" "reflect" "strings" ) type student struct { Name string `ini:"name"` Age int `ini:"age"` } type stu struct { NAME string AGE int } //s为指针类型变量,函数中要改变值必须传指针 func setstudent(s interface{}, m map[string]interface{}) { v := reflect.ValueOf(s).Elem() //求变量中字段数量 for i := 0; i < v...
package myaccessory import ( "github.com/brutella/hc/accessory" "github.com/brutella/hc/service" ) type BridgeStatus struct { *accessory.Accessory BridgingState *service.BridgingState } func NewBridgeStatus(info accessory.Info) *BridgeStatus { acc := BridgeStatus{} acc.Accessory = accessory.New(info, accessory...
/* The package server provides the HTTP server that makes the Comment Parsing service as a RESTful service */ package server import ( "net/http" "commentparser/logging" "commentparser/models" "commentparser/services" "encoding/json" "errors" "github.com/gorilla/mux" "io/ioutil" "net/url" "strings" "time" ...
package rules /* integration test for rules. This separate pkg needed to not create an import cycle between config and rules */ import ( "gopkg.in/yaml.v2" "io/ioutil" "reflect" "sort" "testing" _ "github.com/tumblr/docker-registry-pruner/internal/pkg/testing" "github.com/tumblr/docker-registry-pruner/pkg/con...
/* * 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...
//go:build wasm && js && webclient package main import ( "bytes" "encoding/json" "errors" "log" "net/http" "strconv" "strings" "syscall/js" "time" "github.com/ekotlikoff/gochess/internal/model" matchserver "github.com/ekotlikoff/gochess/internal/server/backend/match" gateway "github.com/ekotlikoff/goches...
package main import "fmt" func main() { // function map1() map2() } func map1() { // map คล้าย dict ใน python x := make(map[string]string) x["TH"] = "Thailand" x["JP"] = "Japan" x["EN"] = "England" fmt.Println(x["TH"]) } func map2() { y := map[string]string{ "TH": "Thailand", "JP": "Japan", } fmt.Pri...
// The MIT License (MIT) // // Copyright (c) 2016 Aya Tokikaze // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, co...
package main import ( "bufio" "compress/gzip" "crypto/sha256" "encoding/hex" "fmt" "hash/fnv" "log" "net/http" "os" "path" "strings" ) const ( entries = 10000 shaSuffix = ".sha256" ) var stories = map[uint32]string{} func handler(w http.ResponseWriter, r *http.Request) { if r.URL.Path == "/" { fmt...
package main import ( "fmt" ) func main() { //<<<<<<< HEAD //<<<<<<< HEAD // fmt.Println("Hello, world and world") fmt.Println("Прывитанне КРАИНА") //<<<<<<< HEAD fmt.Println("Привет МИР!") //======= fmt.Println("привет мир!") fmt.Println("Merhaba, Baris!") //>>>>>>> feature //======= fmt.Println("HELLO...
// Copyright 2020 MongoDB 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 in...
package main import ( "crypto/hmac" "crypto/sha512" "encoding/base64" "encoding/hex" "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" "golang.org/x/crypto/scrypt" ) type Status struct { Code int `json:"code"` Name string `json:"name"` Desc string `json:"de...
package api import ( "database/sql" "fmt" "net/http" "strconv" "time" "github.com/arxdsilva/olist/record" "github.com/arxdsilva/olist/bill" "github.com/labstack/echo" ) // Bill calculates a specific bill of a subscriber // If a month is not specified, It'll be the last // closed month // month and year are ...
package cli import ( "fmt" "github.com/DataDrake/cli-ng/v2/cmd" p2p "github.com/notassigned/p2p-tools/libp2p" "github.com/sirupsen/logrus" ) var Provide = cmd.Sub{ Name: "provide", Alias: "pvd", Short: "Advertise content on the DHT", Args: &ProvideArgs{}, Run: ProvideRun, } type ProvideArgs struct { K...
/* Copyright © 2021 SUSE LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dist...
package store import ( "time" ) type Transaction struct { ID string `sql:"type:uuid"` AccountID string `sql:"type:uuid,notnull"` Account *Account Amount int32 `sql:",notnull"` Title string `sql:",notnull"` OriginalTitle string `sql:",notnull"` Description ...
//go:generate mockery -dir . -name PaymentConfigReader -output ./mocks -filename config_reader.go package datastore import ( "context" "github.com/imrenagi/go-payment/subscription" "github.com/imrenagi/go-payment" "github.com/imrenagi/go-payment/config" "github.com/imrenagi/go-payment/gateway/midtrans" "githu...
package carbon import ( "fmt" uuid "github.com/satori/go.uuid" "github.com/stretchr/testify/assert" "github.com/teploff/otus/hw_6/utils" "io/ioutil" "os" "testing" ) var workDirectoryPath, _ = os.Getwd() // TestCase checking invalid passed limit & offset arguments func TestIncorrectInput(t *testing.T) { srcU...
package handler import ( "encoding/json" "time" "github.com/gorilla/websocket" "github.com/sirupsen/logrus" ) const ( // Time allowed to write a message to the peer. writeWait = 10 * time.Second // Time allowed to read the next pong message from the peer. pongWait = 60 * time.Second // Send pings to peer ...
package main import ( "encoding/csv" "io" "loger" "os" "reflect" "strconv" ) type StaticData interface { GetPathName() string //! 获取路径名 GetName() string //!获取命名 } type StaticDataMgr struct { csvLst map[string]StaticData } func (self *StaticDataMgr) Init() { self.csvLst = make(map[string]StaticData) } ...
package node import ( "fmt" "sync" "github.com/sherifabdlnaby/prism/app/component" "github.com/sherifabdlnaby/prism/pkg/job" "github.com/sherifabdlnaby/prism/pkg/payload" "github.com/sherifabdlnaby/prism/pkg/response" "go.uber.org/zap" ) type createAsyncFunc func(nodeID ID, j job.Job) (*job.Job, error) //Nod...
///////////////////////////////////////////////////////////////////// // arataca89@gmail.com // 20210417 // // func ReplaceAll(s, old, new string) string // // Retorna uma cópia de s substituindo todas as ocorrências de old // por new. // Se old é "" new é inserido na posição 0 e depois de cada caracter. // ...
package main import ( // "fmt" ) func (this *Application) ProjectCreateAction(args []string) { // projectKey := cmdline.ArgumentValue("projectKey") // summary := cmdline.ArgumentValue("summary") // log.Printf("projectKey = %s summary = %s", projectKey, summary) // p := new(client.Project) // p.PKey = projectKey // ...
/* Copyright 2019 The Kubernetes 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, ...
package handler import ( "application/session" "application/config" "application/route" "database/sql" "net/http" ) const ( COOKIE_NAME = "sessionId" ) type Handler struct { Route *route.Route Config *config.Config Session *session.Session DB *sql.DB } func (h...
package godebug //godebug:annotatefile import ( "bytes" "context" "flag" "fmt" "go/ast" "io" "io/ioutil" "math/rand" "os" "os/exec" "path/filepath" "runtime" "strings" "sync" "time" "github.com/jmigpin/editor/core/godebug/debug" "github.com/jmigpin/editor/util/goutil" "github.com/jmigpin/editor/uti...
package main import ( "encoding/json" "log" "net/http" //"bitbucket.org/emicklei/dollar" ) func main() { http.Handle("/", http.FileServer(http.Dir("."))) http.HandleFunc("/recognize", doRecognize) log.Println("dollar test available on http://localhost:8080") log.Fatal(http.ListenAndServe(":8080", nil)) } fu...
package graphQL import ( "fmt" "github.com/graphql-go/graphql" _ "github.com/jinzhu/gorm/dialects/mssql" "github.com/radyatamaa/loyalti-go-echo/src/domain/model" "github.com/radyatamaa/loyalti-go-echo/src/domain/repository" ) type Song model.Song func MerchantResolver(p graphql.ResolveParams) (interface{}, erro...
package dbinstance import ( "context" "encoding/json" "errors" "fmt" "strings" "time" "github.com/kloeckner-i/db-operator/pkg/utils/gcloud" "github.com/kloeckner-i/db-operator/pkg/utils/kci" "github.com/sirupsen/logrus" "golang.org/x/oauth2/google" sqladmin "google.golang.org/api/sqladmin/v1beta4" ) // G...
package radio type SongServer interface { Search(query string) ([]Track, error) Track(id string) (Track, error) } type Tracks struct { Items []Track } type Track struct { Artists []Artist Name string ID string Album Album } type Album struct { Name string Images []Image } type Artist struct { ...
package main import ( "fmt" "os" "time" "github.com/urfave/cli" ) func main() { app := &cli.App{ Name: "release-cli", Usage: "Release in Pegasus's convention", Commands: []cli.Command{ *addCommand, *showCommand, *submitCommand, }, Action: func(c *cli.Context) error { return cli.ShowAppHel...
/* * Copyright 2018-present Open Networking Foundation * 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 ...
// Copyright 2019 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 main import "fmt" func main() { n := 7 i := Fibo1(n) j := Fibo2(n) k := Fibo3(n) fmt.Printf("%v %v %v", i, j, k) } //递归实现 func Fibo1(n int) int { if n == 0 { return 0 } else if n == 1 { return 1 } else if n > 1 { return Fibo1(n-1) + Fibo1(n-2) } else { return -1 } } //迭代实现 func Fibo2(n i...
package codegen import ( "bufio" "context" "fmt" "reflect" "strconv" "strings" "github.com/lithammer/dedent" "github.com/moby/buildkit/client" "github.com/openllb/hlb/errdefs" "github.com/openllb/hlb/parser" "github.com/openllb/hlb/solver" "github.com/pkg/errors" ) type CodeGen struct { Debug D...
package main import "fmt" func main() { // 错误写法 //var m map[string]int //m["frank"] = 1 //fmt.Println(m) // 正确写法 var m2 = make(map[string]int) m2["height"] = 165 fmt.Println(m2) }
package memory_test import ( "testing" "github.com/stretchr/testify/assert" "github.com/disposedtrolley/goz/internal/memory" ) func TestMemoryRead(t *testing.T) { mem := memory.NewMemory([]byte{0xfe, 0xa2, 0x0d, 0x19, 0x00}) assert.Equal(t, uint8(0xfe), mem.ReadByte(0), "should read a byte") assert.Equal(t, ...
/* Forgotten languages (also known as extinct languages) are languages that are no longer in use. Such languages were, probably, widely used before and no one could have ever imagined that they will become extinct at some point. Unfortunately, that is what happened to them. On the happy side of things, a language may ...
package caaa import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00600105 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:caaa.006.001.05 Document"` Message *AcceptorCancellationResponseV05 `xml:"AccptrCxlRspn"` } func (d *Documen...
// +build partners // Stub function for GuessMimeType. This is for partner-apps, where // the function is never actually called. We need the function to be // defined, or our build will fail. // // GuessMimeType is not used in partner apps because it relies on // external C libraries that partners probably will not ha...
package model import ( "github.com/google/uuid" "gorm.io/gorm" ) type ChatUser struct { UUID string `gorm:"type: binary(36);"` Username string `gorm:"type:varchar(255)"` Password string `gorm:"type:varchar(255)"` } func (u *ChatUser) BeforeCreate(tx *gorm.DB) (err error) { //newUUID, err := uuid.NewUUID() ...
package main import ( "encoding/csv" "fmt" "io" "os" ) func main() { years := [9]string{"2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016"} for y := 0; y < len(years); y++ { fmt.Println("Leyendo archivo del", years[y]) file, err := os.Open("../data/" + years[y] + "/directorio_" + years[y...
/* ** description(""). ** copyright('Open_IM,www.Open_IM.io'). ** author("fg,Gordon@tuoyun.net"). ** time(2021/5/13 10:33). */ package logic import ( "Open_IM/pkg/common/config" kfk "Open_IM/pkg/common/kafka" "Open_IM/pkg/common/log" pbChat "Open_IM/pkg/proto/chat" pbRelay "Open_IM/pkg/proto/relay" "github.com/...
package static import ( "fmt" "net/http" "strings" ) type FilesServer struct { baseHRef string hsts bool } func NewFilesServer(baseHRef string, hsts bool) *FilesServer { return &FilesServer{baseHRef, hsts} } func (s *FilesServer) ServerFiles(w http.ResponseWriter, r *http.Request) { // If there is no sto...
/* Copyright 2021 CodeNotary, 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 law or agreed to i...
package sync import ( "sync" "time" ) type Mutex struct { name string mutex *Semaphore lock *sync.Mutex } // NewMutex creates new mutex lock object // name of the mutex // callbackFunc is a release notification function. func NewMutex(name string, callbackFunc func(string)) *Mutex { return &Mutex{ name: n...
package otpauth import ( "bytes" "encoding/json" "errors" "fmt" "io/ioutil" "log" "os" "testing" ) var ( intToBytes Fixture zeroPaddingDigits6 Fixture zeroPaddingDigits8 Fixture decodeBase32 Fixture decodeBase32WithPadding Fixture encodeBase32 Fixture hmacHa...
/** * (c) 2014, Caoimhe Chaos <caoimhechaos@protonmail.com>, * Ancient Solutions. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain ...
package main import ( "fmt" "regexp" ) func main() { re := regexp.MustCompile(`\d+(?:st|nd|rd|th)`) src := "December 19th, 2018" dst := re.ReplaceAllStringFunc(src, func(in string) string { return in[:len(in)-2] }) fmt.Println(dst) }
/* Copyright 2020 The Kubernetes 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, ...
package main import "fmt" func plus(first int, second int) int { return first + second } func plusPlus(a, b, c int) int { return a + b + c } func main() { result := plus(1, 2) fmt.Println(result) result2 := plusPlus(1, 2, 3) fmt.Println(result2) }
// Package selectionsort provides implementation of selection sort package selectionsort import ( "github.com/lzcqd/sedgewick/chap2_sorting/sortable" ) func Sort(data sortable.Interface) { for i := 0; i < data.Len(); i++ { min := i for j := i + 1; j < data.Len(); j++ { if data.Less(j, min) { min = j }...
package Problem0476 func findComplement(num int) int { temp := num res := 0 for temp > 0 { temp >>= 1 res <<= 1 res++ } return res ^ num }
package main import ( "fmt" "log" "net/http" "github.com/cagnosolutions/adb" "github.com/cagnosolutions/web" ) var mux *web.Mux var tmpl *web.TmplCache var db *adb.DB func init() { db = adb.NewDB() db.AddStore("user") db.AddStore("personnelData") db.AddStore("company") mux = web.NewMux() tmpl = web.NewTm...
package cmd const Version = "3.25.1"
package coinbase import ( "log" "os" "testing" ) // Initialize the client with mock mode enabled on rpc // All calls return the corresponding json response from the test_data files func initTestClient() Client { return apiKeyClientTest(os.Getenv("COINBASE_KEY"), os.Getenv("COINBASE_SECRET")) } // About Mock Test...
package main import ( "flag" "math/rand" "os" "time" "github.com/ovirt/csi-driver/internal/ovirt" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" "k8s.io/klog" "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/manager" "github.com/ovirt/csi-...
package bigquery import ( "context" "errors" "fmt" "testing" "time" "cloud.google.com/go/bigquery" "github.com/google/uuid" "github.com/googleapis/google-cloud-go-testing/bigquery/bqiface" "github.com/odpf/optimus/models" "github.com/stretchr/testify/assert" ) func TestBigquery(t *testing.T) { testingCon...
package problem0104 import "testing" func TestSolve(t *testing.T) { node1 := &TreeNode{Val: 3} node2 := &TreeNode{Val: 9} node3 := &TreeNode{Val: 20} node4 := &TreeNode{Val: 15} node5 := &TreeNode{Val: 7} node1.Left = node2 node1.Right = node3 node3.Left = node4 node3.Right = node5 t.Log(maxDepth(node1)) }
package camt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document02600105 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:camt.026.001.05 Document"` Message *UnableToApplyV05 `xml:"UblToApply"` } func (d *Document02600105) AddMessage() *UnableTo...
package types import ( sdk "github.com/hashrs/blockchain/framework/chain-app/types" sdkerrors "github.com/hashrs/blockchain/framework/chain-app/types/errors" ) // RouterKey is used to route messages and queriers to the greeter module const RouterKey = "main-net" // MsgGreet defines the MsgGreet Message type MsgGre...
package main_test import ( "os" "encoding/json" "net/http" "net/url" "net/http/httptest" "testing" "io/ioutil" "fmt" "strings" "bytes" main "webserver" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/sqlite" "golang.org/x/crypto/bcrypt" ) const testUser...
package secret const ( wink = 1 << iota doubleBlink closeYourEyes jump reverse ) var secretHandshakeMap = map[uint]string{ wink: "wink", doubleBlink: "double blink", closeYourEyes: "close your eyes", jump: "jump", } func Handshake(code uint) []string { handshake := []string{} for i := uint(1); i < reverse...
// Copyright 2015 CoreOS, 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 in...
package main import ( "fmt" "github.com/liuzl/fmr" ) type TS struct { *fmr.TableState } func (t *TS) e(ts *TS) bool { if t == nil && ts == nil { return true } if (t != nil && ts == nil) || (t == nil && ts != nil) { return false } return false } func main() { var t *TS ret := t.e(t) fmt.Println(ret) ...
package main import ( "fmt" "hash/crc32" ) func main(){ h := crc32.NewIEEE() fmt.Println(h) fmt.Println(h.Sum32()) }
package birpc_test import ( "encoding/json" "io" "net" "testing" "github.com/tv42/birpc" "github.com/tv42/birpc/jsonmsg" ) type Request struct { Word string } type Reply struct { Length int } type LowLevelReply struct { Id uint64 `json:"id,string"` Result Reply `json:"result"` Error *b...
package solver import ( "fmt" "math/rand" "os" "time" "github.com/Karocyt/Npupu/internal/sortedhashedtree" ) // ScoreFn type: heuristic functions prototype type ScoreFn func([]int, int, int) float32 var size int var goalKey string var goalMap map[int][2]int var finalGrid []int type counters struct { maxState...
package main import "fmt" func main() { // 1、未使用的常亮可以编译通过 // const x = 123 // const y = 1.23 // fmt.Println(x) // 结论:为使用的常量可以编译通过,常量是一个简单值的表示符号, 在程序运行的时候不会被修改。 // 2、未初始化的常量的情况 // const ( // x uint16 = 120 // y // c // s = "abc" // z // ) // fmt.Printf("%T %v \n", y, y) // fmt.Printf("%T %v ...
package main import ( "github.com/gin-contrib/pprof" "github.com/gin-gonic/gin" "qqfav-service/config" "qqfav-service/filters" "qqfav-service/filters/auth" routeRegister "qqfav-service/routes" "net/http" //proxy "github.com/chenhg5/gin-reverseproxy" ) func initRouter() *gin.Engine { router := gin.New() rou...
package api import ( "net/http" "encoding/json" "io/ioutil" ); const API_BASE_URL = "https://www.kimonolabs.com/api/ck52w24s" const API_KEY_TCODE = "tEqeo1dz9ZfMuUvCeR55gM80kT6AkJzX" type TcodeResponse struct { Tcode string `json:"tcode"` Status string `json:"status"` } func GetTcode(ncode string) (string, erro...
package main import "log" type ledger struct{} func (l *ledger) makeEntry(ID string, t string, a float64) { log.Printf("make ledger entry for account %s with %s type for amount %v", ID, t, a) }
package jpush type Audience struct { PushAudience interface{} //推送目标 AudienceInfo map[string][]string //推送标签/范围/注册id } const ( STag = "tag" //标签 STagAnd = "tag_and" //标签and SALias = "alias" //别名(暂时只使用这个) SRegistrationId = "registration_id" //注册id...
package intersect import ( "reflect" "sort" "testing" ) func Test_intersect(t *testing.T) { type args struct { nums1 []int nums2 []int } tests := []struct { name string args args want []int }{ // TODO: Add test cases. { name: "first", args: args{ nums1: []int{1, 2, 3, 4}, nums2: []i...
package main import ( "fmt" "github.com/shopspring/decimal" ) func main() { fmt.Println("decimal sample") price, err := decimal.NewFromString("136.02") if err != nil { panic(err) } quantity := decimal.NewFromInt(3) fee, _ := decimal.NewFromString(".035") taxRate, _ := decimal.NewFromString(".08875") ...
package etcd import ( "context" "github.com/coreos/etcd/mvcc/mvccpb" "go.etcd.io/etcd/clientv3" "sync" "time" ) /* ETCD服务发现 */ type EtcdDiscovery struct { client *clientv3.Client services map[string]string // 注册的服务列表 lock sync.Mutex prefixName string // 服务名前缀 } /* 创建服务发现实例 */ func NewEtcdDisco...
package object type ( Tag struct { ID uint String string } Tags []*Tag )
package models // //import ( // db "test/database" //) // //type Person struct { // Id int `json:"id" form:"id"` // Name string `json:"name" form:"name"` // Age int `json:"age" form:"age"` //} // //func (p *Person) AddPerson () (id int64, err error) { // rs, err := db.SqlDB.Exec("INSERT INTO test(name, age) V...
package nominetuk // Copy this file and place as credentials.go const ( Username = "Example" Password = "Example" )
// Copyright 2016 IBM Corporation // // 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...