text
stringlengths
11
4.05M
package geckoclient // DataType defines a interface type which exposes a single method // for returning field values of type details. It helps to construct // the values sent along a NewDataset field list for items to be created // on the geckoboard API. type DataType interface { Field() map[string]interface{} } // ...
// Copyright 2016 The Gem Authors. All rights reserved. // Use of this source code is governed by a MIT license // that can be found in the LICENSE file. package gem import ( "bufio" "bytes" "errors" "fmt" "io/ioutil" "net" "net/http" "os" "reflect" "runtime" "strings" "testing" "time" "github.com/valy...
package main import ( "encoding/json" "fmt" "github.com/pkg/errors" "io/ioutil" "log" "net/http" ) type ThunderstoreVersion struct { FullName string `json:"full_name"` } type ThunderstorePackage struct { FullName string `json:"full_name"` Versions []ThunderstoreVersion `json:"versions"` } type Thunderstore...
package openshift import ( "os" "path/filepath" "github.com/openshift/installer/pkg/asset" "github.com/openshift/installer/pkg/asset/templates/content" ) const ( azureCloudProviderSecretFileName = "99_azure-cloud-provider-secret.yaml.template" azureCloudProviderSecretGetterRoleBindingFileName ...
package main import ( "io/ioutil" "fmt" "net/http" ) func httpGet() { resp, err := http.Get("http://127.0.0.1:8080/abc") if err != nil { // handle error } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { // handle error } fmt.Println(s...
package models import ( "github.com/astaxie/beego/orm" "time" ) //查询的类 type OtcOrderQueryParam struct { BaseQueryParam //发布时间 StartTime int64 `json:"startTime"` //开始时间 EndTime int64 `json:"endTime"` //截止时间 VendorPhone string `json:"vendorPhone"` //买方手机号 VendeePhone string `json:"vendeePhone"` //...
package network import ( "fmt" "sort" "strings" "github.com/quilt/quilt/db" "github.com/quilt/quilt/join" "github.com/quilt/quilt/minion/ovsdb" "github.com/quilt/quilt/stitch" log "github.com/Sirupsen/logrus" ) func updateACLs(client ovsdb.Client, connections []db.Connection, labels []db.Label) { syncAddre...
package llq import ( "fmt" "io" "github.com/ymotongpoo/goltsv" ) func DoList(in io.Reader) error { r := goltsv.NewReader(in) record, err := r.Read() if err != nil { return err } for k, _ := range record { fmt.Println(k) } return nil }
package cmd import ( "fmt" "os" "github.com/spf13/cobra" ) var rootCmd = &cobra.Command{ Use: "csla", Short: "csla is a project template generator to Create Serverless Application", Long: `A simple and easy understand project template generator focus in building Serverless Application using terraform as bac...
package main import "log" func main() { var isTrue bool isTrue = true if isTrue == true { log.Println("isTrue is", isTrue) } else { log.Println("isTrue is", isTrue) } // ------------------------------------------- cat := "cat" if cat == "cat" { log.Println("CAT!") } else { log.Println("NO CAT!") }...
// Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 package tcp import ( "fmt" "io" "net" "strings" "time" "github.com/iotaledger/wasp/plugins/gracefulshutdown" ) func (n *NetImpl) iteratePeers(f func(p *peer)) { n.peersMutex.Lock() defer n.peersMutex.Unlock() for _, peer := range n.pee...
package practices import ( "github.com/stretchr/testify/assert" "testing" ) func Test_solution(t *testing.T) { tcs := []struct { Places [][]string Result []int }{ { [][]string{{"POOOP", "OXXOX", "OPXPX", "OOXOX", "POXXP"}, {"POOPX", "OXPXP", "PXXXO", "OXXXO", "OOOPP"}, {"PXOPX", "OXOXP", "OXPOX",...
type canceler interface { cancel(removeFromParent bool, err error) Done() }
package server import ( "fmt" "io" "io/ioutil" "net" "os" "path/filepath" "syscall" "github.com/Sirupsen/logrus" "github.com/kubernetes-incubator/cri-o/oci" "github.com/kubernetes-incubator/cri-o/utils" "golang.org/x/net/context" pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" kubecontainer "k8s....
package node import ( "fmt" "net/http" "github.com/jhampac/xkattle/database" ) const httpPort = 9000 type ErrRes struct { Error string `json:"error"` } type BalancesRes struct { Hash database.Hash `json:"block_hash"` Balances map[database.Account]uint `json:"balances"` } type TxAddReq struct...
package fracker_test import ( "github.com/onsi/ginkgo" "github.com/onsi/gomega" f "github.com/shopkeep/fracker" "log" "os" "testing" ) type TestClient struct { StubGet func(string) (f.Node, error) } func (self *TestClient) Get(key string) (f.Node, error) { return self.StubGet(key) } func TestFracker(t *tes...
package functions // Intersect returns items that exist in all lists. // // It returns slice without any duplicates. // If zero slice arguments are provided, then nil is returned. func (ss SliceType) Intersect(slices ...SliceType) (ss2 SliceType) { if slices == nil { return nil } var uniqs = make([]map[ElementTy...
package storage import ( "github.com/danielkrainas/shrugmud/config" ) var ( drivers map[string]StorageDriverFactory = make(map[string]StorageDriverFactory) ) func RegisterDriver(key string, factory StorageDriverFactory) { drivers[key] = factory } type StorageDriverFactory func() StorageDriver type StorageDriver...
package dispatch import ( "context" "encoding/json" "errors" "fmt" "strings" "time" "github.com/antonmedv/expr" log "github.com/sirupsen/logrus" "google.golang.org/grpc/metadata" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimac...
package models import "github.com/astaxie/beego/orm" type MvType struct { Id int Name string Url string ImgSrc string IconImgSrc string Description string Status int } func (mvType *MvType) TableName() string { return "mv_type" } func GetCategory() (*[]MvType, error) { o ...
package clipboard import ( "os/exec" //"github.com/pkg/errors" ) type xclipboard struct { CopyCmd []string PasteCmd []string } func newXClipBoard() *xclipboard { xclip := &xclipboard{ CopyCmd: []string{"xclip", "-in", "-selection", "clipboard"}, PasteCmd: [...
package test_test import ( "context" "strings" "testing" "github.com/ipfs/go-cid" "github.com/filecoin-project/specs-actors/v2/actors/migration/nv4" "github.com/filecoin-project/specs-actors/v2/actors/runtime" "github.com/filecoin-project/specs-actors/v2/actors/states" addr "github.com/filecoin-project/go-a...
package logentry import "github.com/danielchatfield/go-chalk" // Section represents a secion header type Section struct { msg string } // NewSection returns a new Section with the specified message func NewSection(msg string) *Section { return &Section{msg: msg} } func (s *Section) String() string { return chalk...
// Copyright (c) 2016-2018, Jan Cajthaml <jan.cajthaml@gmail.com> // // 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 require...
package main import "fmt" func main() { var l float32 var w float32 fmt.Printf("What is the length of the room in feet? ") fmt.Scanf("%f", &l) fmt.Printf("What is the width of the room in feet? ") fmt.Scanf("%f", &w) fmt.Printf("The area is\n%.3f square feet\n%.3f square metres", l*w, l*w*0.09290304) }
package assets import ( "net/http" "os" "path" "github.com/owncloud/ocis-hello/pkg/config" "github.com/owncloud/ocis/v2/ocis-pkg/log" ) //go:generate make -C ../.. embed.yml // assets gets initialized by New and provides the handler. type assets struct { logger log.Logger config *config.Config } // Open jus...
package dtos type AutocompleteRequest struct { Prefix string } type AutocompleteResponse struct { Result []string `json:"result"` }
package gosnowth import ( "context" "net/http" "net/http/httptest" "net/url" "strings" "testing" ) const testLuaExtensionData = `{ "test": { "documentation": "# test\nReturns parsed payload ", "method": null, "PARSE_JSON_PAYLOAD": true, "params": { "tests": { "type": "list", "default": [], ...
package cats import ( "context" "net/http" "github.com/NYTimes/marvin" "google.golang.org/appengine/log" ) func (s *service) listCats(ctx context.Context, _ interface{}) (interface{}, error) { // get cats from injected DB cats, err := s.db.GetCats(ctx) if err != nil { log.Errorf(ctx, "unable to get cat li...
package db import ( "encoding/json" "fmt" "github.com/go-redis/redis" "os" "redis_proxy/app/models" ) var ( ADDR = os.Getenv("REDIS_URL") ) func RedisClient() *redis.Client { return redis.NewClient(&redis.Options{ Addr: ADDR, Password: "", // no password set DB: 0, // use default DB }) } fu...
package print import ( "sort" "github.com/ns1/jsonschema2go/internal/composite" "github.com/ns1/jsonschema2go/internal/slice" "github.com/ns1/jsonschema2go/internal/tuple" "github.com/ns1/jsonschema2go/pkg/gen" ) func defaultSort(plans []gen.Plan) []gen.Plan { sorted := make([]gen.Plan, len(plans)) copy(sorte...
package gov import ( "fmt" "sort" "strconv" "strings" "time" sdk "github.com/ColorPlatform/color-sdk/types" ) const ( // FirstBlockHeight condation of block heigh reach to 1 FirstBlockHeight = 1 // LimitFirstFundingCycle condation first funding cycle should start after 4 weeks LimitFirstFundingCycle = 0 /...
/* Copyright 2020 Daniel Avrukin 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 dis...
package pg import ( "github.com/kyleconroy/sqlc/internal/sql/ast" ) type AlterTSDictionaryStmt struct { Dictname *ast.List Options *ast.List } func (n *AlterTSDictionaryStmt) Pos() int { return 0 }
package main import ( "strings" "github.com/pkg/errors" ) // validateOutputFormat validates that the requested output format (for // commands) that support this option, is valid. It returns when an unrecognized // format is requested. func validateOutputFormat(outputFormat string) error { switch strings.ToLower(o...
package main import ( "fmt" golog "log" "net/http" "github.com/vhaoran/vchat/common/g" "github.com/vhaoran/vchat/lib" "github.com/vhaoran/vchat/lib/yetcd" "github.com/vhaoran/vchat/lib/ylog" "vchatdemo/unit/impl" "vchatdemo/unit/intf" ) var ( // 每个微服务都不同,这里需要更改 // todo msTag = "api" host = "0.0.0....
package goinsight import ( "fmt" "unsafe" ) type typeAlg struct { // function for hashing objects of this type // (ptr to object, seed) -> hash hash func(unsafe.Pointer, uintptr) uintptr // function for comparing objects of this type // (ptr to object A, ptr to object B) -> ==? equal func(unsafe.Pointer, unsa...
/* Command xo is a command line utility that takes an input string from stdin and formats the regexp matches. */ package main import ( "fmt" "io/ioutil" "os" "regexp" "strings" ) func main() { if len(os.Args) == 1 { help() } arg := os.Args[1] stat, _ := os.Stdin.Stat() if (stat.Mode() & os.ModeCharDevice...
package piper import ( "context" ) // status is a struct used to communicate the results of a worker's last batch job type status struct { address chan *batch // worker's channel to send new batches results *batch // results of the previously run batch } // worker is an object used execute the user-defined b...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //214. Shortest Palindrome //Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the s...
// Copyright 2021 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 utils import "fmt" import "time" func TimeTrack(start time.Time, name string) { elapsed := time.Since(start) fmt.Printf("%s in .............. %v \n", name, elapsed) }
// 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 main import "testing" func TestMinDiff(t *testing.T) { testData := []struct { in []int diff int }{ {[]int{1, 99, -9, 10, 3, 44}, 2}, {[]int{1, 99, -9, 10, 100, 44}, 8}, } for i, td := range testData { answer := minAbsDiff(td.in) if answer != td.diff { t.Errorf("Test %d. Input %v. Expected...
package paths import ( "os" "path/filepath" "testing" ) func TestGetPaths(t *testing.T) { t.Run("should return correct paths without environment variables set", func(t *testing.T) { t.Setenv("RD_LOGS_DIR", "") homeDir, err := os.UserHomeDir() if err != nil { t.Errorf("Unexpected error getting user home d...
// Reads in an HCL file and converts it to JSON on stdout or the specified file. package main import ( "encoding/json" "fmt" "io/ioutil" "os" "path" "github.com/hashicorp/hcl" ) func main() { // Check arguments if len(os.Args) <= 1 { fmt.Fprintf(os.Stderr, "Usage: %s <input file> [output file]\n", path.Bas...
package main import ( "fmt" "os" ) func check(e error) { if e != nil { panic(e) } } func main() { dat, err := os.ReadFile("./dat") check(err) fmt.Println(string(dat)) f, err := os.Open("./dat") check(err) b1 := make([]byte, 5) n1, err := f.Read(b1) check(err) fmt.Printf("%d bytes: %s\n", n1, string(...
package problem0378 import "testing" func TestSolve(t *testing.T) { t.Log(kthSmallest([][]int{[]int{1, 5, 9}, []int{10, 11, 13}, []int{12, 13, 15}}, 8)) }
/** 1. Create a func with identifier foo that - takes a variadic parameter of type int - pass in a value of type []int into your function - returns the sum of all the values of type int passed in 2. Create a func with the identifier bar that - takes in a parameter of type []int - returns the sum of...
package mysqldb import ( "context" "time" ) // Device 用于表示设备信息 type Device struct { DeviceID int `gorm:"primary_key"` // 表记录标识 MAC int64 `gorm:"column:mac"` // 测量设备的MAC地址 Sn string `gorm:"column:sn"` // SN号 Pin string ...
package main import ( "bufio" "fmt" "math" "os" "sort" "strconv" ) func getInput() map[int][]int { file, _ := os.Open("input.txt") defer file.Close() adapters := make(map[int][]int) maxJolt := 0 scanner := bufio.NewScanner(file) for scanner.Scan() { num, _ := strconv.Atoi(scanner.Text()) adapters[nu...
package xeno import ( reflect "reflect" "testing" gomock "github.com/golang/mock/gomock" ) func TestPlayer_ShowForClairvoyance(t *testing.T) { p := Player{ hand: Hand{cards: []int{10}}, } got := p.ShowForClairvoyance() want := 10 if got != want { t.Errorf("want:%v, got: %v", want, got) } } func TestPl...
// Package opensimplex provides an implementation of the OpenSimplex Noise // algorithm in 2, 3 and 4 dimensions. // // OpenSimplex Noise generates "visually axis-decorrelated coherent noise", // similar to Perlin's Simplex noise, but unencumbered by patents. // // The algorithm was created by Kurt Spencer (see his pos...
/* Copyright 2020 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...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2019-12-16 15:12 # @File : wallet_tree.go # @Description : # @Attention : */ package wallet import ( "github.com/emirpasic/gods/utils" "myLibrary/go-libary/go/trees/avltree" ) var ( // PATH_COMPARATOR = func(a, b interface{}) int { // a1, a2 := a.(string), ...
package tool var CliVersion string
package paths import ( "os" "path/filepath" "testing" ) func TestGetPaths(t *testing.T) { t.Run("should return correct paths without environment variables set", func(t *testing.T) { // Ensure that these variables are not set in the testing environment environment := map[string]string{ "RD_LOGS_DIR": ""...
package main import ( "encoding/json" "fmt" "html/template" "log" "net/http" "strconv" "strings" cache "github.com/patrickmn/go-cache" ) /* * Routes */ // SMS API sends func receivePlivoSMS(w http.ResponseWriter, r *http.Request) { // log.Println("receivePlivoSMS", r.Method) if r.Method != "POST" { ...
package response import ( "encoding/json" errs "errors" "github.com/bob620/baka-rpc-go/errors" ) type Types string const ( SuccessType Types = "success" ErrorType Types = "error" ) type Response struct { responseType Types id string jsonRpc string result *json.RawMessage error ...
package DAO import ( "Work_5/object" "github.com/jinzhu/gorm" ) //创建新的文章 func CreateArticle(article *object.Article, db *gorm.DB) object.ErrMessage { if !db.HasTable(&article) { db.AutoMigrate(&article) } db.Create(&article) return object.ErrMessage{} } //查询文章是否存在 func ArticleQuerry(article *object.Article...
package mysqldb import ( "context" "time" ) // ScannedQRCodeRecord 二维码扫码记录 type ScannedQRCodeRecord struct { RecordID int32 `gorm:"primary_key"` // 记录ID SceneID int32 `gorm:"scene_id"` // 场景ID CreatedAt time.Time // 创建时间 UpdatedAt time.Time // 更新时间 DeletedAt *time.Time // 删除时间 } // TableName...
/* 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 main import "fmt" func main() { var test int = 1 fmt.Printf("%T\n", test) var test1 float32 = float32(test) //test被转换的是变量存储的数据(即值),test变量本身的数据类型并没有发生变化,还是int fmt.Printf("%T,%T\n", test1, test) //在转换中,高精度转低精度,编译不会报错,转换结果按溢出处理,和我们想要的结果不一样 var age int64 = 555333333 var test3 = int8(age) fmt.Println(tes...
package runtime import "github.com/qlova/script" //Plus implements implements script.Language.Plus func (runtime *Runtime) Plus(a, b script.Int) script.Int { var x, y = *a.T().Runtime, *b.T().Runtime return script.Int{Type: Value(a.Ctx, func() interface{} { return x().(int) + y().(int) })} } //Join implements ...
package database import ( "encoding/json" "io/ioutil" ) var genesisJSON = ` { "genesis_time": "2020-11-11T00:00:00.000000000Z", "chain_id": "xkattle-ledger", "balances": { "alice": 1000000 } }` type genesis struct { Balances map[Account]uint `json:"balances"` } func loadGenesis(path string) (genesis, err...
package main import ( "flag" "net" "fmt" "go.uber.org/zap" "google.golang.org/grpc" "github.com/bclermont/whereru/proto" "github.com/bclermont/whereru/server" ) func main() { // initialize zap logger logger, err := zap.NewDevelopment() if err != nil { panic(err) } port := flag.Uint("port", 8080, "Por...
// Package v1 contains API Schema definitions for the kube v1 API group // +k8s:deepcopy-gen=package,register // +groupName=kube.hub.appvia.io package v1
package main import ( "bufio" "fmt" "os" "strconv" "strings" ) func ConvertToInts(strnums []string) ([]int, error) { nums := make([]int, 0) for _, val := range strnums { num, err := strconv.Atoi(val) if err != nil { return nil, err } nums = append(nums, num) } return nums, nil } func FilterEvenIn...
package file_service import ( "fmt" "os/exec" ) type Resizer struct { InputFullPath string OutputFullPath string Quality int Width int } func (f *Resizer) ResizeFFMPEG() { if f.Width <= 0 { f.Width = 100 } scale := fmt.Sprintf("scale=%d:-1", f.Width) arg := []string{ "-i", f.InputFul...
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package cmd import ( "bytes" "os" "path/filepath" "testing" "github.com/spf13/viper" "github.com/vespa-engine/vespa/client/go/mock" ) func newTestCLI(t *testing.T, envVars ...string) (*CLI, *bytes.Buffer, *...
package bitbucket import ( "fmt" ) type Source struct { Node string `json:"node"` Path string `json:"path"` Data string `json:"data"` Size int64 `json:"size"` } // Use the Bitbucket src resource to browse directories and view files. // This is a read-only resource. // // https://confluence.atlassian.com/displa...
package fsm import ( "fmt" "sort" ) // VisualizeType the type of the visualization type VisualizeType string const ( // GRAPHVIZ the type for graphviz output (http://www.webgraphviz.com/) GRAPHVIZ VisualizeType = "graphviz" // MERMAID the type for mermaid output (https://mermaid-js.github.io/mermaid/#/stateDiag...
package main import ( "flag" "net/http" "os" "github.com/go-kit/kit/log" httptransport "github.com/go-kit/kit/transport/http" "golang.org/x/net/context" ) func main() { var ( listen = flag.String("listen", ":8080", "HTTP listen address") proxy = flag.String("proxy", "", "Optional comma-separated list of...
package main import ( "bufio" "fmt" "os" "crypto/sha256" "encoding/hex" ) func hash(s string) string { b := []byte(s) shad := sha256.Sum256(b) return hex.EncodeToString(shad[:32]) } func validate(user string, pass string) bool { KNOWN := map[string]string { "piokozi" : "5...
/* The GolfScript language has one serious lack, no float or fixed point handling. Remedy this by creating a function F for converting an integer number, given as a string, to a string representing 1 / 10 000 000 000 of it's value. The function must handle both positive and negative values as well as leading 0s. The ...
package main import ( "fmt" "sync" ) type contact interface { GetName() string SetName(string) } type BasicContactFactory struct{} func (bcf *BasicContactFactory) MakeContact() contact { return &basicContact{} } // START OMIT type basicContact struct { //implements sync.Locker, contact sync.Mutex name strin...
package fasdas import ( "bufio" "fmt" "io" "os" "strconv" "strings" ) /* 1.Создать функцию которая проходится по массиву введенному пользователем проверяет его на условие введенное пользователем если все условия соблюдены вернет true если нет false */ func main() { checkArray() // Передавать в функцию аргу...
/* Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive). The binary search tree is guaranteed to have unique values. */ package main import ( "fmt" "math" ) func main() { const null = math.MinInt32 test([]int{10, 5, 15, 3, 7, null, 18}, 7, 1...
// Copyright 2017 The go-darwin 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 hdiutil import ( "fmt" "os/exec" "regexp" "strconv" ) // attachFlag implements a hdiutil attach command flag interface. type attachFlag int...
package main import "fmt" func vals() (string, string) { return "returned value 1", "returned value 2" } func main() { val1, val2 := vals() fmt.Println(val1) fmt.Println(val2) // ignore returned first value _, val22 := vals() fmt.Println(val22) }
package app import ( "encoding/xml" "fmt" "io/ioutil" "net/http" "os" "time" "github.com/fernandoporazzi/yak-shop/app/controller" "github.com/fernandoporazzi/yak-shop/app/entity" "github.com/fernandoporazzi/yak-shop/app/service" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" ) func Start...
package data type SuccessFail struct { Code string `json:"code"` Msg string `json:"msg"` Data []DataSuccessFail `json:"data"` } type DataSuccessFail struct { } //作者接口文档 //获取作者列表 //1-关注作者列表的成功响应 type AuthorListFollow struct { Code string `json:"code"` Msg string ...
package ds import "sort" /** * * * * * Given an array of integers arr, replace each element with its rank. The rank represents how large the element is. The rank has the following rules: Rank is an integer starting from 1. The larger the element, the larger the rank. If two elements are equal,...
//////////////////////////////////////////////////////////////////////////////// // // // Copyright 2023 Broadcom. The term Broadcom refers to Broadcom Inc. and/or // // its subsidiaries. ...
package scraper import ( "github.com/PuerkitoBio/goquery" "github.com/codeskyblue/go-sh" "github.com/mgutz/logxi/v1" "github.com/paulbellamy/ratecounter" "github.com/ungerik/go-dry" // "github.com/kennygrant/sanitize" "encoding/json" "fmt" "os" "runtime" "strings" "time" "github.com/rober...
package algorithms import ( "fmt" "github.com/mhereman/cryptotrader/interfaces" "github.com/mhereman/cryptotrader/logger" ) var algoFactory map[string]func() (interfaces.IAlgorithm, error) = make(map[string]func() (interfaces.IAlgorithm, error)) // RegisterAlgorithm registers an new algorithm factory function. /...
// Copyright 2019 The Dice Authors. 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by app...
package spec import ( "github.com/agiledragon/trans-dsl" "github.com/agiledragon/trans-dsl/test/context" ) type IsSpecialConditionSatisfied struct { } func (this *IsSpecialConditionSatisfied) Ok(transInfo *transdsl.TransInfo) bool { stubInfo := transInfo.AppInfo.(*context.StubInfo) return stubInfo.X == "special"...
package main import ( "encoding/json" "fmt" ) type Response1 struct { Page int Fruits []string } func main() { fltB, _ := json.Marshal(2.34) fmt.Println(string(fltB)) resp1 := Response1 { Page:3, Fruits: []string{"Apple", "Orange", "Pear"} } obj1, _ := json.Marshal(resp1) fmt.Println(...
package mint import ( "testing" "time" stakeTypes "github.com/irisnet/irishub/app/v1/stake/types" sdk "github.com/irisnet/irishub/types" "github.com/stretchr/testify/require" ) func TestNextInflation(t *testing.T) { minter := NewMinter(time.Now(), stakeTypes.StakeDenom, sdk.NewIntWithDecimal(100, 18)) tests :...
package memcache_service import ( "fmt" c "github.com/patrickmn/go-cache" "ms/sun_old/base" "ms/sun/shared/golib/go_map" "ms/sun/shared/x" "time" ) var contactsCache = c.New(time.Hour*24, time.Minute*1) func DoesUserInPhoneContacts(MeId, PeerId int) bool { //fmt.Println("mmm", MeId,PeerId) if MeId < 1 || Pee...
package model_service import ( "ms/sun/servises/event_service" "ms/sun/servises/memcache_service" "ms/sun/shared/helper" "ms/sun/shared/x" "ms/sun_old/base" ) /* spec: 1: following 2: requested 0: not following or could not */ func Follow(UserId, FollowedPeerUserId int) int { if UserId == FollowedPe...
package models import "time" //用户行为记录 func (a *AdminModelRecord) TableName() string { return AdminModelRecordTBName() } type AdminModelRecord struct { Id int `orm:"pk;column(id)"json:"id"form:"id"` //uid Uid int `orm:"column(uid)"json:"uid"form:"uid"` //操作 Handle string `orm:"column(handle)"json:"handle"form:...
package main import ( "os" "testing" "time" "github.com/stretchr/testify/assert" ) func TestMain(m *testing.M) { list := make(map[int]User) dt, _ := time.Parse(time.RFC3339, "1985-12-31T00:00:00Z") list[0] = User{0, "John", "Doe", dt, "London"} dt, _ = time.Parse(time.RFC3339, "1992-01-01T00:00:00Z") list[1...
package gosign import ( "crypto/rand" "crypto/rsa" "crypto/sha256" "crypto/x509" "encoding/base64" "encoding/pem" "io/ioutil" "log" "net/http" "net/http/httptest" ) // Handler is the http.Handler implementation for the Signature Handler. type Handler struct { next http.Handler priv *rsa.PrivateKey } // N...
package 链表 func reverseList(head *ListNode) *ListNode { var pre, next *ListNode cur := head for cur != nil { next = cur.Next cur.Next = pre pre = cur cur = next } return pre } /* 题目链接: https://leetcode-cn.com/problems/fan-zhuan-lian-biao-lcof/ */
package configparser import ( "fmt" "gopkg.in/yaml.v2" ) type yamlTypeMap map[interface{}]interface{} type yamlTypeArray []interface{} // ParseYamlConfig - read data while type=YAML func ParseYamlConfig(data []byte, macroParser MacroParserFunc) (map[string]string, map[string]interface{}, error) { m := make(yamlM...
package leetcode func checkStraightLine(coordinates [][]int) bool { dx, dy := coordinates[1][0]-coordinates[0][0], coordinates[1][1]-coordinates[0][1] lc := len(coordinates) for i := 2; i < lc; i++ { tx, ty := coordinates[i][0]-coordinates[i-1][0], coordinates[i][1]-coordinates[i-1][1] if ty*dx != dy*tx { re...
package main import "fmt" type person struct { first string last string favIcecream []string } func main() { people := []person{ { first: "nick", last: "green", favIcecream: []string{"chochlate", "ass"}, }, { first: "todd", last: "wells", favIcecream: ...
package dslog import ( "bytes" "context" "fmt" "regexp" "strings" "testing" "github.com/MakeNowJust/heredoc/v2" "go.mercari.io/datastore" "go.mercari.io/datastore/dsmiddleware/dslog" "go.mercari.io/datastore/testsuite" "google.golang.org/api/iterator" ) // TestSuite contains all the test cases that this p...