text
stringlengths
11
4.05M
package main import "fmt" func main() { var numOfTests int fmt.Scanf("%d", &numOfTests) var a, b int for i := 0; i < numOfTests; i++ { fmt.Scanf("%d %d", &a, &b) if b == 0 { fmt.Println("divisao impossivel") continue } result := float32(a) / float32(b) fmt.Printf("%.1f\n", result) } }
package controller type response struct { Description string Content interface{} }
package log import ( "sync" "github.com/gogf/gf/frame/g" "github.com/gogf/gf/os/glog" ) var _logger *glog.Logger var _loggerOnce sync.Once const logName = "cnbs" // init init func init() { if err := NewLogger().SetConfigWithMap(g.Map{ // "path": "/var/log", "level": "all", "stdout": true, "St...
/** *@Author: haoxiongxiao *@Date: 2019/1/28 *@Description: CREATE GO FILE models */ package models import ( "fmt" "time" "github.com/garyburd/redigo/redis" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" "github.com/lexkong/log" "github.com/spf13/viper" "gopkg.in/mgo.v2" ) type Database ...
package okex_websocket import . "exchange_websocket/common" type OkexCylce struct { OkexCycles []string OkexCycleMap map[string]int } func NewOkexCycle() *OkexCylce { okCycle := new(OkexCylce) return okCycle.OkexCycleInit() } func (o *OkexCylce) OkexCycleInit() *OkexCylce { o.OkexCycles = []string{"1min", "3...
package allow_list import ( "context" "fmt" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" ) func DeployedDockerImages(kubernetesClient kubernetes.Interface, kubernetesNamespace string) ([]string, error) { var deployedDockerImages []string images, err := getPodsImages(kubernetesCl...
// +build nobootstrap package hashes import ( "encoding/hex" "fmt" "runtime" "strings" "gopkg.in/op/go-logging.v1" "build" "core" "parse" ) var log = logging.MustGetLogger("hashes") // RewriteHashes rewrites the hashes in a BUILD file. func RewriteHashes(state *core.BuildState, labels []core.BuildLabel) {...
// Copyright 2016 Sevki <s@sevki.org>. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package internal is used for registering types in build, it had no clear place // in other packages to go which is why it gets it's own package package ...
package util import ( tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" ) func GetAcceptingMessage(message *MessageData, acceptingString string) tgbotapi.MessageConfig { msg := tgbotapi.NewMessage(message.Chat.ID, acceptingString) row := make([]tgbotapi.KeyboardButton, 0) yesBtn := tgbotapi.NewKeyboardB...
package leetcode /*Given a m * n matrix mat of ones (representing soldiers) and zeros (representing civilians), return the indexes of the k weakest rows in the matrix ordered from the weakest to the strongest. A row i is weaker than row j, if the number of soldiers in row i is less than the number of soldiers in row ...
// Command reposize takes a newline-separated list of github repos on stdin, // clones them, computes their size, deletes them, and outputs to stdout // a CSV table with rows of sizebytes,repo. package main // import "github.com/ijt/reposize" import ( "bufio" "flag" "fmt" "io/ioutil" "log" "net/http" "os" "os...
package main /* * @lc app=leetcode id=145 lang=golang * * [145] Binary Tree Postorder Traversal */ /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func prepend(s []int, t int) []int { s = append(s, 0) copy(s[1:], s) s[0] =...
package postgres import ( "database/sql" "database/sql/driver" "errors" "fmt" ) type PostgresDriver struct { } func (d PostgresDriver) Open(string) (driver.Conn, error) { fmt.Println("Open a postgres driver") return nil, errors.New("UnImplemented") } var d *PostgresDriver func init() { d = new(PostgresDrive...
package main import "fmt" func main() { // START OMIT i := 0 fmt.Printf("%d\n", i++) // END OMIT }
package test import ( "testing" "sync" "fmt" "time" "sub_account_service/order_server/entity" "sub_account_service/order_server/dto" "encoding/json" "bytes" "sub_account_service/order_server/utils" ) func TestAddOrder(t *testing.T) { var wg sync.WaitGroup timeStamp := fmt.Sprintf("%v",time.Now().Unix() * 1...
// Copyright 2020 Readium Foundation. All rights reserved. // Use of this source code is governed by a BSD-style license // that can be found in the LICENSE file exposed on Github (readium) in the project repository. package index import ( "database/sql" "testing" _ "github.com/mattn/go-sqlite3" "github.com/rea...
/* Package context "Every package should have a package comment, a block comment preceding the package clause. For multi-file packages, the package comment only needs to be present in one file, and any one will do. The package comment should introduce the package and provide information relevant to the package as a who...
package service import ( "errors" "fmt" "github.com/13283339616/orm" "github.com/13283339616/util" "github.com/13283339616/vo" ) type HelloService struct { } func (h HelloService) Index(v vo.LoginRequestVo) (token string, err error) { u := orm.User{} user := u.GetUserByUserCode(v.Username) if user == nil { ...
// Copyright (C) 2021 Cisco Systems 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 agr...
// Copyright 2015 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 modules import ( "encoding/json" "fmt" "io/ioutil" "log" "strings" "github.com/interstellar/kelp/model" "github.com/interstellar/kelp/support/logger" "github.com/interstellar/kelp/support/utils" "github.com/stellar/go/build" "github.com/stellar/go/clients/horizon" ) // DexWatcher is an object that ...
/* API - API functions. */ package main import ( "encoding/json" "net/http" ) /* Pool - the pool data for creating of the user. */ type Pool struct { Pool string `json:"pool"` User string `json:"user"` Password string `json:"password"` } /* API - API functions. */ type API struct{} /* ServeHTTP - web h...
package beans var MetricsInfluxdb = "" //性能统计influxdb地址 var MachineNo = "" //机器编码 var RunMode = "dev" //运行模式
package assert import ( "testing" ) func TestAssert(t *testing.T) { var i interface{} = "1" defer Catch(func(violation Violation) { t.Logf("Cacth Violation: %s", violation) }) _ = Int(i) t.Errorf("not panic") }
package main import ( "bufio" "bytes" "fmt" "math" "os" "strconv" "strings" ) func main() { s := bufio.NewScanner(os.Stdin) // file, _ := os.Open(os.Stdin) // s := bufio.NewScanner(file) buf := new(bytes.Buffer) buf.Grow(1024 * 1024) s.Buffer(buf.Bytes(), 1024*1024) s.Scan() n, err := strconv.Atoi(s.T...
package goauth import "time" // testClient implements the Client interface and is // intended for use only in testing. type testClient struct { ID string secret string username string redirectURI string scope []string } // AllowStrategy satisfies the Client interface, returning true if th...
package chunk import ( "encoding/binary" "io" "github.com/tombell/go-serato/internal/decode" ) // Vrsn is a chunk that contains the version of the Serato session file format. type Vrsn struct { header *Header data []byte } // Header returns the header for the chunk. func (v *Vrsn) Header() *Header { return ...
package main type DataPoint interface { GetValue(attributeName string) Attribute //gets an attribute based on the name of the attribute given SetValue(attributeName string, valToSet Attribute) error //sets the attribute value, throws an error if they aren't the right types GetAttributeValues(targetName string) map[...
package dbsrv import ( "github.com/empirefox/esecend/front" "github.com/empirefox/reform" ) func (dbs *DbService) ProductsFillResponse(products ...reform.Struct) (*front.ProductsResponse, error) { if len(products) == 0 { return nil, reform.ErrNoRows } var ids []interface{} for _, p := range products { ids ...
package Problem0461 import ( "fmt" "testing" "github.com/stretchr/testify/assert" ) // tcs is testcase slice var tcs = []struct { x int y int ans int }{ { 3, 1, 1, }, { 1, 4, 2, }, // 可以有多个 testcase } func Test_hammingDistance(t *testing.T) { ast := assert.New(t) for _, tc := range ...
// Code generated from Cypher.g4 by ANTLR 4.7.2. DO NOT EDIT. package parser // Cypher import "github.com/antlr/antlr4/runtime/Go/antlr" // A complete Visitor for a parse tree produced by CypherParser. type CypherVisitor interface { antlr.ParseTreeVisitor // Visit a parse tree produced by CypherParser#oC_Cypher. ...
package accountdb import( "stockdb" // "util" "fmt" ) const ( Truncate = "truncate table %s" ) type FinancialIndexDB struct{ stockdb.DBBase } func (s *FinancialIndexDB) Create(sqls []string) int { //db := s.Open() for _, sql := range sqls { s.ExecOnce(sql) } return 0 } ...
package tools /* //string到int int,err:=strconv.Atoi(string) //string到int64 int64, err := strconv.ParseInt(string, 10, 64) //int到string string:=strconv.Itoa(int) //int64到string string:=strconv.FormatInt(int64,10) //string到float32(float64) float,err := strconv.ParseFloat(string,32/64) //float到string string :=...
package main import ( "admigo/common" c "admigo/controllers" "admigo/controllers/api" "github.com/julienschmidt/httprouter" "net/http" ) func getRouter() (router *httprouter.Router) { router = httprouter.New() router.ServeFiles("/static/*filepath", http.Dir(common.Env().Static)) router.GET("/", c.Index) rout...
package _6_datatype_conversion import ( "fmt" "strconv" "testing" ) func TestIntToFloat(t *testing.T) { // 基本数据类型相互转换,不能自动转换,必须强制转换(显式转换) var i = 100 var f float64 = float64(i) t.Logf("i=(%d,%T),f=(%f,%T)\n", i, i, f, f) // i=(100,int),f=(100.000000,float64) } func TestFloatToInt(t *testing.T) { var f = 3.14...
package handler import ( "context" "errors" "time" "github.com/golang/protobuf/ptypes" "github.com/google/uuid" crypto "github.com/jinmukeji/go-pkg/v2/crypto/encrypt/legacy" "github.com/jinmukeji/go-pkg/v2/crypto/rand" "github.com/jinmukeji/jiujiantang-services/jinmuid/mysqldb" bizcorepb "github.com/jinmukej...
package validate /* *********************************************** GlobalOption Struct *********************************************** */ // GlobalOption settings for validate type GlobalOption struct { // FilterTag name in the type tags. FilterTag string // ValidateTag in the type tags. ValidateTag string /...
// +build varlink,!remoteclient package main import ( "fmt" "net" "os" "path/filepath" "strings" "time" "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/cmd/podman/libpodruntime" "github.com/containers/libpod/libpod" "github.com/containers/libpod/pkg/adapter" api "github.c...
package main import ( "errors" "fmt" "github.com/hyperledger/fabric/core/chaincode/shim" ) // AssetsChaincode creates assets type AssetsChaincode struct { } func main() { err := shim.Start(new(AssetsChaincode)) if err != nil { fmt.Printf("Error starting AssetsChaincode chaincode: %s", err) } } // Init is w...
// Copyright 2019-2023 The sakuracloud_exporter 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 appl...
// Copyright (c) 2019-2020 Tigera, 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 ...
package main import ( "bufio" "fmt" "io" "io/ioutil" "log" "net" "os" "path" "strings" ) func main() { listener, err := net.Listen("tcp", "localhost:2222") if err != nil { log.Fatal(err) } for { conn, err := listener.Accept() if err != nil { log.Print(err) continue } go handleConn(conn) ...
package mut import ( "time" ) const defaultMaxRetryTime = time.Second * 60 type retry struct { maxRetryTime time.Duration tempDelay time.Duration retryTime int } func newValidRetry(maxRetryTime time.Duration) *retry { return &retry{ maxRetryTime: maxRetryTime, tempDelay: 0, retryTime: 0, } } f...
package scanner import "go/token" // compatible enums const ( eIllegal = int(token.ILLEGAL) tEOF = int(token.EOF) tComment = int(token.COMMENT) tIdentifier = int(token.IDENT) tInt = int(token.INT) tFloat = int(token.FLOAT) tImag = int(token.IMAG) tRune = int(token.CHAR) tSt...
// Package testkit provides tools for testing Go code. package testkit
package persistence import ( "context" "database/sql" "strings" "github.com/dollarshaveclub/acyl/pkg/models" "github.com/lib/pq" "github.com/pkg/errors" ) var _ HelmDataLayer = &PGLayer{} func (pg *PGLayer) GetHelmReleasesForEnv(ctx context.Context, name string) ([]models.HelmRelease, error) { if isCancelled...
package main // 配置 type Config struct { Debug bool `json:"debug"` //Debug模式 ServerUrl string `json:"serverUrl"` //服务端地址包含端口 Version string `json:"version"` //当前版本 }
package core import ( "context" "github.com/jybbang/go-core-architecture/core" ) type testModel struct { core.Entity Expect int `bson:"expect,omitempty"` } type okCommand struct { Expect int } type errCommand struct { Expect int } func okCommandHandler(ctx context.Context, request interface{}) core.Result {...
package db import ( "fmt" "math/rand" "reflect" "sort" "testing" "time" "github.com/davecgh/go-spew/spew" "github.com/stretchr/testify/assert" ) func TestMachine(t *testing.T) { conn := New() var m Machine err := conn.Txn(AllTables...).Run(func(db Database) error { m = db.InsertMachine() return nil ...
package entity import ( "reflect" "time" ) type ArticleTagEntity struct { Id int64 `mysql:"id" redis:"id" json:"Id"` ArticleId int64 `mysql:"article_id" redis:"article_id" json:"ArticleId"` TagId int64 `mysql:"tag_id" redis:"tag_id" json:"TagId"` CreatedTime time.Time `mysql:"create...
package main import ( "fmt" "gee" "net/http" ) func indexHandler(c *gee.Context) { fmt.Fprintf(c.Writer, "URL.Path = %q\n", c.Req.URL.Path) } func helloHandler(c *gee.Context) { for k, v := range c.Req.Header { fmt.Fprintf(c.Writer, "Header[%q] = %q\n", k, v) } } func main() { r := gee.New() r.Use(gee.Re...
package main import ( "encoding/json" "io" "log" "net/http" "os" "strings" "sync" "github.com/PuerkitoBio/goquery" "github.com/syndtr/goleveldb/leveldb" ) func getHTMLPage(url string) *goquery.Document { // Request the HTML page. res, err := http.Get(url) if err != nil { println("ERROR GET") return n...
package model import "time" type Humidity struct { Id int64 `json:"id"` Value float32 `json:"value"` Timestamp time.Time `json:"timestamp"` } type Humidities []Humidity func (this Humidity) GetId() (int64) { return this.Id } func (this Humidity) GetValue() (float32) { return this.Value }...
/* Copyright (C) 2021 The Falco 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, s...
package libs import ( "net/http" "github.com/labstack/echo/v4" ) type Api struct{} // 实例化 func NewApi() *Api { return &Api{} } // 接口响应成功 // 200 业务返回成功调用 func (a *Api) Ok(c echo.Context, data interface{}) error { return c.JSON(http.StatusOK, map[string]interface{}{ "code": 0, "msg": "ok", "data": data, ...
package model import ( "gopkg.in/mgo.v2/bson" ) type ( Pokemons struct { ID bson.ObjectId `json:"id" bson:"_id,omitempty"` Name string `json:"name" bson:"name"` Element string `json:"element" bson:"element"` Weight string `json:"weight" bson:"weight"` } )
package models import ( "container/list" ) type EventType int const ( EVENT_MESSAGE = iota EVENT_JOIN EVENT_LEAVE ) type Event struct { Type EventType Uid string Timestamp int Content string } const archiveSize = 20 var archive = list.New() // NewEvent add a New Event to archive list func Ne...
package main import ( "errors" "fmt" "strconv" ) func numberInput() (int, error) { fmt.Print("Select Number (1 ~ ) : ") var nstr string fmt.Scanf("%s", &nstr) num, err := strconv.ParseUint(nstr, 10, 64) if err != nil { return -1, errors.New("Wrong Number") } return int(num), nil } func Menu(data []stri...
package osbuild2 import ( "bytes" "encoding/json" "reflect" "testing" ) func TestSource_UnmarshalJSON(t *testing.T) { type fields struct { Type string Source Source } type args struct { data []byte } tests := []struct { name string fields fields args args wantErr bool }{ { name: ...
package model import ( "database/sql" "fmt" ) type Action struct { ID int `json:"id"` UUID string `json:"uuid"` User string `json:"user"` Device string `json:"device"` Active bool `json:"active"` } func (action *Action) CreateAction(db *sql.DB) error { var active int if action.Active { activ...
package AlgoeDB import ( "errors" "regexp" ) func MoreThan(value float64) QueryFunc { return func(target interface{}) bool { number, err := getNumber(target) if err != nil { return false } return number > value } } func MoreThanOrEqual(value float64) QueryFunc { return func(target interface{}) bool ...
package parsecsv import ( "bufio" "errors" "fmt" "github.com/IhorBondartsov/csvReader/entity" "os" "sync" ) type Reader interface { StartRead() } type ReaderCfg struct { Result chan entity.PersonData Path string Parser Parser Workers int BufferSize int } func NewReader(cfg ReaderCfg) (R...
package _1_合并两个有序链表 type ListNode struct { Next *ListNode Val int } // 21. 合并两个有序链表 https://leetcode-cn.com/problems/merge-two-sorted-lists/ // 输入:l1 = [1,2,4], l2 = [1,3,4] // 输出:[1,1,2,3,4,4] func mergeTwoLists(l1 *ListNode, l2 *ListNode) *ListNode { head := &ListNode{Val: 0, Next: nil} curr := head for l1 !=...
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. package armhelpers import ( "context" "time" "github.com/Azure/aks-engine/pkg/kubernetes" "github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization" "github.com/Azure/azure-sdk-for-go/se...
package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "os" "path/filepath" "text/template" "filippo.io/age" "github.com/glassechidna/actions2aws" "github.com/pkg/errors" ) func main() { //exitEarlyOnForks() switch os.Args[1] { case "keygen": keygen() case "request": request()...
package main import ( "fmt" "time" ) func main() { fmt.Println("Igual =", "x" == "y") fmt.Println("Igual =", 5 == 5.0) fmt.Println("Diferente =", 5 != 4) fmt.Println("Maior =", 5 > 4) fmt.Println("Menor =", 2 < 4) fmt.Println("Maior ou igual =", 5 > 4) fmt.Println("Menor ou igual =", 2 < 4) data1 := time.U...
package baremetal import ( "fmt" "net" "strings" "github.com/openshift/installer/pkg/types" "github.com/openshift/installer/pkg/types/baremetal" ) // TemplateData holds data specific to templates used for the baremetal platform. type TemplateData struct { // ProvisioningInterfaceMAC holds the interface's MAC a...
package mock import ( "context" "payment/internal/dto" "payment/internal/models" "github.com/stretchr/testify/mock" ) //AccountRepositoryMock ... type AccountRepositoryMock struct { mock.Mock } //IsExist ... func (a AccountRepositoryMock) IsExist(ctx context.Context, id int) error { args := a.Called(ctx, id)...
package lt349 // 两个数组的交集 //给定两个数组,编写一个函数来计算它们的交集。 // //示例 1: // //输入: nums1 = [1,2,2,1], nums2 = [2,2] //输出: [2] //示例 2: // //输入: nums1 = [4,9,5], nums2 = [9,4,9,8,4] //输出: [9,4] //说明: // //输出结果中的每个元素一定是唯一的。 //我们可以不考虑输出结果的顺序。 // //来源:力扣(LeetCode) //链接:https://leetcode-cn.com/problems/intersection-of-two-arrays //著作权...
package github import ( "encoding/json" "errors" "fmt" "os" "github.com/nkprince007/igitt-go/lib" ) var gitHubBaseURL string func init() { gitHubBaseURL = func() string { url, exists := os.LookupEnv("GITHUB_BASE_URL") if !exists { return "https://api.github.com" } return url }() } type repository...
/* Copyright 2022 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, softw...
/* * @lc app=leetcode.cn id=147 lang=golang * * [147] 对链表进行插入排序 */ // @lc code=start /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ package main import "fmt" type ListNode struct { Val int Next *ListNode } func insertionSortList(head *ListNod...
package main import( "log" "os" "context" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "grpc-demo/api" ) const ( //address ="127.0.0.1:22222" //defaultName = "world" // TLS认证选项 OpenTLS = true ) // customCredential 自定义认证 type customCredential struct {} func (...
package main import ( "crypto/aes" "crypto/cipher" "crypto/md5" "crypto/rand" "encoding/hex" "fmt" "io" "io/ioutil" "log" "os" "time" rand1"math/rand" "github.com/Binject/debug/pe" ) // DetectDotNet - returns true if a .NET assembly. 2nd return value is detected version string. func DetectDotNet(filena...
package main import ( "context" "flag" "fmt" "github.com/sfomuseum/go-flags/multi" "github.com/whosonfirst/go-reader" "github.com/whosonfirst/go-whosonfirst-travel-image/util" "log" ) func main() { var sources multi.MultiString flag.Var(&sources, "source", "One or more filesystem based sources to use to rea...
package ag // Default repository names. const ( InfoRepo = "course-info" AssignmentRepo = "assignments" TestsRepo = "tests" SolutionsRepo = "solutions" StudentRepoSuffix = "-labs" ) // StudentRepoName returns the name of the given student's repository. func StudentRepoName(userName string...
// Copyright 2014, Roger Fernandez Guri. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import () func main() { }
package main import ( "context" "flag" "fmt" "github.com/sfomuseum/go-flags/multi" "github.com/whosonfirst/go-reader" "github.com/whosonfirst/go-whosonfirst-geojson-v2" "github.com/whosonfirst/go-whosonfirst-travel" "github.com/whosonfirst/go-whosonfirst-travel-image/render" "github.com/whosonfirst/go-whosonf...
// apply.go - apply a resolution to failed CheckSet verification package checkset import ( "../futility" "errors" "io" "os" "path" ) // function which returns an open stream for reading a file, when // given its remote relative path. type Retriever func(string) (io.ReadCloser, error) var ExistingSpecial = erro...
package main import ( "bufio" "fmt" "os" "time" "strings" "log" "github.com/google/uuid" "github.com/sandertv/gophertunnel/minecraft" "github.com/sandertv/gophertunnel/minecraft/protocol/login" "github.com/sandertv/gophertunnel/minecraft/protocol/packet" ) func main() { // Connect to the ...
package rpc_service func pan(string string) { } func toLimit(paramLimit int32, defualtLimit int) int { limit := defualtLimit if paramLimit != 0 { limit = int(paramLimit) } return limit }
package pie import ( "errors" "net/http" "github.com/jmcvetta/napping" ) var ( UrlPrefix = "https://api.piethis.com/v1" session = &napping.Session{ Header: &http.Header{"Pie-Online": []string{"1",}}, } ) type request struct { Url string Token string ExtraParams map[string]string Payload inter...
package main import ( ) // Swagger 1.2 Specification Structures type SwaggerAPI12 struct { SwaggerVersion string `json:"swaggerVersion"` APIVersion string `json:"apiVersion"` BasePath string `json:"basePath"` ResourcePath string `json:"resourcePath"` APIs []API `json:"apis"` Models map[string]Model...
/* Package cli provides an advanced CLI framework. Commands are defined as structs wich must be registerd with Register(T). type Command struct { // The parent command must always be present and the first field // It defaults to cli.Root ban it can be any command type. cli.Root // The name of the ...
package smpp34 var ( reqUnbindRespFields = []string{} ) type UnbindResp struct { *Header mandatoryFields map[string]Field tlvFields map[uint16]*TLVField } func NewUnbindResp(hdr *Header) (*UnbindResp, error) { s := &UnbindResp{Header: hdr} return s, nil } func (s *UnbindResp) GetField(f string) Field {...
// This file was generated for SObject Lead, API Version v43.0 at 2018-07-30 03:47:38.089446383 -0400 EDT m=+24.432969612 package sobjects import ( "fmt" "strings" ) type Lead struct { BaseSObject Address *Address `force:",omitempty"` AnnualRevenue string `force:",omitempty"` City ...
package gobyexample import ( "fmt" "github.com/lukekhamilton/goAdventures/goByExample/pkg" ) var xyz = 4 // Pkg ... func Pkg() { var x = 1 var y int var ip *int ip = &x y = *ip fmt.Printf("%+v\n", x) fmt.Printf("%+v\n", y) fmt.Printf("%+v\n", *ip) fmt.Printf("%+v\n", ip) fmt.Printf("%+v\n", &x) fmt.P...
/* * @lc app=leetcode.cn id=283 lang=golang * * [283] 移动零 */ package main import "fmt" // @lc code=start func moveZeroes(nums []int) { left, right, n := 0, 0, len(nums) for right < n { if nums[right] != 0 { nums[left], nums[right] = nums[right], nums[left] left++ } right++ } } // @lc code=end func...
package database type TbMeterReading struct { // gorm.Model ID uint MeterID string Recordnum int ReadingType1 string Value1 float64 ReadingType2 string Value2 float64 Ts string Status int8 ReadingType string Value float64 } func (TbMeterReading) Table...
package utils import ( "errors" "github.com/astaxie/beego" "github.com/astaxie/beego/orm" "go_blog/models" ) func RegisterUser(username, password string) (error) { o := orm.NewOrm() user := models.User{Username:username,Password:Md5Encrypted(password)} _, err := o.Insert(&user) if err != nil { beego.Warn("r...
func detectCapitalUse(word string) bool { r:=[]rune(word) for i:=0;i<len(r);i++{ if r[i]>='A' && r[i]<='Z'{ if i>0 && !(r[i-1] >='A' && r[i-1]<='Z'){ return false } if i<len(r)-1 &&i!=0 && !(r[i+1] >='A' && r[i+1]<='Z'){ return false ...
package main import ( "bufio" "fmt" "os" // "strings" // "strconv" ) // readLines reads a whole file into memory // and returns a slice of its lines. func readLines(path string) ([]string, error) { file, err := os.Open(path) if err != nil { panic(err) } defer file.Close() var li...
package bindex import ( "bytes" "sort" ) type Cursor struct { bindex *BIndex stack []elemRef } func (c *Cursor) seek(seek []byte) (key []byte, value []byte) { c.search(seek, c.bindex.root) //for i := 0; i < len(c.stack); i++ { // e := c.stack[i] //} ref := &c.stack[len(c.stack)-1] if ref.count() == 0 || r...
package auth import ( "regexp" "conor.co.za/vservices/golib/logger" "github.com/jansemmelink/api" "github.com/jansemmelink/sweeper" ) //UserLibrary ... type UserLibrary struct { } //Operations ... func (lib UserLibrary) Operations() map[string]api.Operation { return map[string]api.Operation{ "register": Regi...
package main import ( "fmt" "io/ioutil" "net/http" "net/url" "strings" "sync" "time" ) type Producer struct { client *http.Client } type HostsPair struct { RelativeURL string Errors []error Left, Right Host } type Host struct { StatusCode int Body []byte URL *url.URL Error erro...
package govAutomation import ( "bytes" "encoding/json" "errors" "fmt" "io/ioutil" "net/http" ) const ( machineBasePath = "catalog-service/api/consumer" entitledCatalogItemsPath = machineBasePath + "/entitledCatalogItems" requestsPath = machineBasePath + "/requests" resour...
package status import ( "github.com/wajox/gobase/internal/app/build" ) // Response is a declaration for a status response type Response struct { ID string `jsonapi:"primary,status"` Status string `jsonapi:"attr,status"` Build *build.Info `jsonapi:"attr,build"` }
package main import ( "log" "strconv" "strings" "github.com/QisFj/godry/slice" ) func main() { is := []int{1, 2, 3, 4, 5, 6} ss := slice.Map(is, func(i int, v int) string { return strconv.Itoa(v) }) log.Printf("after map: %#v\n", ss) ss = slice.Filter(ss, func(_ int, v string) bool { return strings.Cont...
package main import "fmt" func main() { var colores = [...]string{"rojo", "amarillo", "azul", "rosa"} fmt.Println(colores) fmt.Println(len(colores)) colores[1] = "verde" fmt.Println(colores) }
package main import "fmt" func main() { //var arr [2]int //var index int = 3 //arr[index] = 6 //编译器不报错,但是运行会越界 var arr = [3]int{0, 1, 3} fmt.Printf("%v\n", arr) //数组值传递 test(arr) fmt.Printf("%v\n", arr) var arr1 = [3]int{5, 6, 7} fmt.Printf("%v\n", arr1) //数组引用传递 test1(&arr1) fmt.Printf("%v\n", arr1) } ...