text
stringlengths
11
4.05M
package repo //UsersRepoStruct your function for query db, consume another service cant define here type UsersRepoStruct struct { } type UsersInterface interface { CreateUsers() error } func UsersTokenRepoImp() UsersInterface { return &UsersRepoStruct{} } func (g *UsersRepoStruct) CreateUsers() error { return n...
package generator_test import ( "fmt" "github.com/bmdelacruz/generator" ) func ExampleGenerator_Next() { // Generator func that doesn't call any of the controller // functions and returns a nil value fmt.Println("Case 1:") g1 := generator.New( func(gc *generator.Controller) (interface{}, error) { return ...
// Copyright 2017 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package db import ( _ "github.com/lib/pq" "github.com/stretchr/testify/mock" ) type MockEmployeeRepo struct { mock.Mock } // List returns all employee records func (m *MockEmployeeRepo) List() ([]Employee, error) { args := m.Called() if args.Get(0) == nil { return nil, args.Error(1) } return args.Get(0).([]...
package main import "fmt" func main() { phone := "13564663499" if len(phone) != 11 { fmt.Println("invalid") } str := fmt.Sprintf("%s****%s", phone[0:3], phone[7:11]) fmt.Println(str) }
package main import ( "fmt" "log" "io/ioutil" "os" // "strings" "regexp" "mustard/utils/page_analysis" "mustard/internal/github.com/PuerkitoBio/goquery" "strings" "mustard/internal/gopkg.in/mgo.v2" ) func check(e error) { if e != nil { panic(e) } } type Fang struct { // 标题,小区,租金,户型,地址,配...
package usecases import ( "github.com/falcosecurity/cloud-native-security-hub/pkg/vendor" ) type RetrieveOneVendor struct { VendorID string VendorRepository vendor.Repository } func (useCase *RetrieveOneVendor) Execute() (res *vendor.Vendor, err error) { return useCase.VendorRepository.FindById(useCase.V...
package caster import "testing" func BenchmarkToInt16(b *testing.B) { c := NewCaster() b.ResetTimer() for i := 0; i < b.N; i++ { c.ToInt16(123, -1) c.ToInt16(int32(123), -1) c.ToInt16(int64(123), -1) c.ToInt16(int16(12), -1) c.ToInt16(int8(1), -1) c.ToInt16(float32(123), -1) c.ToInt16(float64(123), ...
package main import ( //"log" "net/http" "time" //"github.com/gorilla/context" "github.com/gorilla/mux" //"github.com/gorilla/sessions" "io" "os" ) func init() { InitApp() InitLog() InitDb() InitAppCfg() //InitSendMail() InitMinify() } func main() { r := mux.NewRouter() r.PathPrefix("/public/").Han...
package exchange import ( "context" "encoding/json" "encoding/xml" "fmt" "os" "path/filepath" "regexp" "sort" "strconv" "testing" "github.com/prebid/openrtb/v19/openrtb2" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/exchange/entities" "github.com/prebid/prebid-server/openrtb...
package repository import ( "errors" "time" "github.com/darren-west/app/user-service/models" "gopkg.in/mgo.v2" "github.com/hashicorp/errwrap" ) var EmptyMatcher = NewMatcher() type Matcher map[string]interface{} func (m Matcher) WithID(id string) Matcher { m["id"] = id return m } func (m Matcher) WithFirs...
// Copyright 2018 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package network import ( "context" "io/ioutil" "os" "path/filepath" "strings" "time" "chromiumos/tast/common/shillconst" "chromiumos/tast/local/network" "chromiumo...
package main import ( "context" "flag" "fmt" "os" "github.com/google/subcommands" "github.com/malice-plugins/go-plugin-utils/utils" ) type crackCmd struct { } func (p *crackCmd) Name() string { return "crack" } func (p *crackCmd) Synopsis() string { return "crack a password file" } ...
package main import "fmt" type Integer int func (a *Integer) Add(b Integer) Integer { return *a + b } //func (a Integer) Add(b Integer) Integer { // return a + b //} func main() { var a Integer = 1 var b Integer = 2 var i interface{} = &a sum := i.(*Integer).Add(b) fmt.Println(sum) }
package public import ( "github.com/google/go-querystring/query" "github.com/pkg/errors" "github.com/potix/gobitflyer/api/types" "github.com/potix/gobitflyer/client" ) const ( getBoardPath string = "/v1/getboard" ) type GetBoardResponse struct { MidPrice float64 `json:"mid_price"` Bids []*G...
package helper import ( "encoding/csv" "log" "os" "time" "bitbucket.org/babulal107/go-app/config" ) func GenerateCSV(fileName string, data [][]string) error{ var ( path string writer *csv.Writer file *os.File err error ) path = config.FileExportPath+GetFileName(fileName)+config.FileExtenuationCSV if...
package go_dj import ( "testing" ) func TestContainer(t *testing.T) { c := NewContainer() s := &tService{} c.Register("controller", func(args ... interface{}) interface{} { return &tController{args[0].(*tService)} }, "service") c.Register("service", func(args ... interface{}) interface{} { return s }) ...
package load /* #cgo LDFLAGS: -lperfstat #include <libperfstat.h> */ import "C" import ( "github.com/elastic/beats/libbeat/common" "github.com/elastic/beats/libbeat/common/cfgwarn" "github.com/elastic/beats/metricbeat/mb" ) // init registers the MetricSet with the central registry as soon as the program // starts...
package odoo import ( "fmt" ) // MailAliasMixin represents mail.alias.mixin model. type MailAliasMixin struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` AliasContact *Selection `xmlrpc:"alias_contact,omptempty"` AliasDefaults *String `xmlrpc:"alias_defaults,omptempty"` Al...
/* Copyright 2019 The Skaffold 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, sof...
/* Created on 2018/11/30 10:26 author: ChenJinLong Content: */ package main import ( "fmt" "strings" ) type Normal func(a int, b ...string) func Afunc(first int, second ...string) { fmt.Println(first) fmt.Println(strings.Join(second, ";")) } func main() { f := Normal(Afunc) f(1, "wwww", "cccc") }
package server import ( "context" "encoding/json" "log" "math" "math/big" "net/http" "strconv" "time" "github.com/NotSoFancyName/SimpleWebServer/persistance" "github.com/gorilla/mux" ) const ( readTimeout = 10 * time.Second writeTimeout = 10 * time.Second maxHeaderBytes = 1 << 20 apiURL = "/api/b...
package cachemocks import ( "github.com/stretchr/testify/mock" "github.com/Skipor/memcached/cache" ) // Cache is an autogenerated mock type for the Cache type type Cache struct { mock.Mock } // Delete provides a mock function with given fields: key func (c *Cache) Delete(key []byte) bool { ret := c.Called(key) ...
// Copyright 2019 Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in complian...
// Copyright 2014 Dirk Jablonowski. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Implementation of a connector interface type with buffered channels. // A buffered working connector. The buffer size for incoming and outgoing events coul...
package bitfield type BitField struct { fields []byte }
// Copyright 2019 The gVisor Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
package loadtester import ( "fmt" "time" "github.com/project-flogo/core/data/metadata" "github.com/project-flogo/core/support/log" "github.com/project-flogo/core/trigger" ) var triggerMd = trigger.NewMetadata(&Settings{}, &Output{}) func init() { trigger.Register(&Trigger{}, &Factory{}) } type Factory struct...
package datasourcetest import ( "github.com/kdimak/go_datasource/datasource" "testing" ) type TestConfig struct { DS datasource.WritableDataSource } func TestWritableDataSource(t *testing.T, tc TestConfig) { tests := []struct { title string run func(t *testing.T, c TestConfig) }{ {"should store and read...
package docs import _ "embed" //go:embed swagger.yml var SwaggerSpecs []byte
package worker import ( "github.com/orbs-network/orbs-contract-sdk/go/context" "github.com/orbs-network/orbs-network-javascript-plugin/test" "github.com/stretchr/testify/require" "testing" ) func TestMethodDispatcher(t *testing.T) { handler := test.AFakeSdkFor([]byte("signer"), []byte("caller")) dispatcher := N...
package main import ( "fmt" "math/rand" ) func matrix() [][]int{ var matrix = make([][]int, 10) for i := range matrix { matrix[i] = make([]int, 10) for j := range matrix[i] { matrix[i][j] = rand.Intn(100) } } return matrix } func main(){ m := matrix() fmt.Println(m) }
package routers import ( entities "github.com/JIeeiroSst/togo/internal/storages" "github.com/JIeeiroSst/togo/models" "github.com/gin-gonic/gin" "time" ) func TaskList(c *gin.Context){ tags,err:=models.TagsList() if err != nil { c.JSON(200,entities.RestResponse{ Code: 200, Message: "no data found", ...
package cmd import ( "ktmall/bootstrap" "github.com/spf13/cobra" ) var serverCmd = &cobra.Command{ Use: "server", Short: "run app server", Run: func(cmd *cobra.Command, args []string) { // init db bootstrap.SetupDB() defer bootstrap.CloseDB() // run echo bootstrap.RunServer() }, } func init() { ...
/***************************************************************************** * file name : STable.go * author : Wu Yinghao * email : wyh817@gmail.com * * file description : 数据层 * ******************************************************************************/ package DataLayer import ( "encoding/binary" ...
package catalog import ( "os" "path/filepath" "strings" "gopkg.in/yaml.v3" ) func LoadFromDirectory(dir string) (*Config, error) { var data Config // list all yaml files in directory loadErr := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { if err != nil { return err } if ...
// 给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效。 // 有效字符串需满足: // 左括号必须用相同类型的右括号闭合。 // 左括号必须以正确的顺序闭合。 // 注意空字符串可被认为是有效字符串。 // 示例 1: // 输入: "()" // 输出: true // 示例 2: // 输入: "()[]{}" // 输出: true // 示例 3: // 输入: "(]" // 输出: false // 示例 4: // 输入: "([)]" // 输出: false // 示例 5: // 输入: "{[]...
package tracer import ( "errors" "fmt" "io" "os" "strings" "github.com/nkbai/tgo/debugapi" "github.com/nkbai/tgo/tracee" "golang.org/x/arch/x86/x86asm" ) const chanBufferSize = 64 // ErrInterrupted indicates the tracer is interrupted due to the Interrupt() call. var ErrInterrupted = errors.New("interrupted"...
package azure_test import ( "errors" "github.com/genevieve/leftovers/azure" "github.com/genevieve/leftovers/azure/fakes" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Groups", func() { var ( client *fakes.GroupsClient logger *fakes.Logger filter string groups azure.Groups ...
package httpx import ( "context" "fmt" "io" "net" "net/http" "strings" "time" ) // Decorator wraps/decorate a http.Handler with additional functionality. type Decorator func(http.Handler) http.Handler // AddHeaderDecorator returns a decorator that adds the given header to the HTTP response. func AddHeaderDeco...
package main import ( "encoding/json" "io" "net/http" "go.uber.org/zap" ) // Colors is response of api type Colors struct { Colors []struct { Value string `json:"value"` } `json:"colors"` } func decodeBody(body io.Reader, out interface{}) error { decoder := json.NewDecoder(body) return decoder.Decode(out)...
package main import "fmt" func main() { s := `Lorem Ipsum is simply "dummy text" of the printing and typesetting industry.` fmt.Println(s) }
/* Copyright © 2020 Yueming Xu <yxu@tibco.com> This file is subject to the license terms contained in the license file that is distributed with this file. */ package main import "github.com/yxuco/tcmdtool/cmd" func main() { cmd.Execute() }
// Copyright 2019 Blues Inc. All rights reserved. // Use of this source code is governed by licenses granted by the // copyright holder including that found in the LICENSE file. package noteutil import ( "encoding/json" "flag" "fmt" "github.com/blues/note-go/notecard" "github.com/blues/note-go/notehub" "io/iou...
// Copyright 2017 YTD Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. // ytd program entry. package main import ( "flag" "fmt" _ "net/http/pprof" "os" "runtime" "runtime/pprof" "strings" "github.com/Ch3ck/youtube-dl/api" ...
package lfsapi import ( "fmt" "io/ioutil" "net/http" "os" "path/filepath" "testing" "github.com/stretchr/testify/assert" ) var testCert = `-----BEGIN CERTIFICATE----- MIIDyjCCArKgAwIBAgIJAMi9TouXnW+ZMA0GCSqGSIb3DQEBBQUAMEwxCzAJBgNV BAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRAwDgYDVQQKEwdnaXQtbGZzMRYw FAYDVQQDEw1na...
package most_common_word import ( "testing" "github.com/stretchr/testify/assert" ) func Test_mostCommonWord(t *testing.T) { tests := []struct { paragraph string banned []string want string }{ { paragraph: "Bob hit a ball, the hit BALL flew far after it was hit.", banned: []string{"hit"},...
package cparser import ( "sync" "ntoolkit/commands" "ntoolkit/errors" "ntoolkit/parser/tools" ) // CommandParser is a high level interface for dispatching text commands. type CommandParser struct { Commands *commands.Commands blockParser *tools.BlockParser factory []CommandFactory } // New returns a n...
package benchcore import ( "crypto/tls" "fmt" "io" "io/ioutil" "net/http" "sync" "sync/atomic" "time" ) type BenchCore struct { Request *http.Request // go-http request struct Concurrency int // 并发数 start time.Time // 开始时间 end time.Time ...
package skeleton type ( Context interface { Valid() bool GetString() string } )
package main import "fmt" func main() {//0 1 2 3 4 5 6 7 8 9 s := []int{10, 11, 12, 42, 43, 44, 45, 46, 47, 48, // 10 11 12 13 14 49, 50, 51, 18, 19} for i, v := range s { fmt.Println(i, v) } fmt.Printf("The type is %T\n", s) fmt.Println("Output should be: 42 43 44 45 46", s[3:8]) fm...
package handlers type BaseResponse struct { StatusEvent string `json:"status_event"` } const ( GET = ".get" POST = ".post" PUT = ".put" DELETE = ".delete" CALLED = ".called" SUCCESS = ".success" STARTED = ".starte...
// Copyright (C) 2023 Storj Labs, Inc. // See LICENSE for copying information. package sync2 import ( "context" "runtime" "testing" "github.com/stretchr/testify/require" "storj.io/common/testcontext" ) func requireBlocked(t *testing.T, ch chan struct{}) { select { case <-ch: t.Fatal("channel read or close...
package golog // LogMsgCtx holds information about a log message type LogMsgCtx struct { // Name is the identifier of the logger Name string // Level is the name of the message log level Level string // Msg is the log message contents Msg string } // NewLogMsgCtx creates a new LogMsgCtx func NewLogMsgCtx(name...
// httping 0.9.1 - A tool to measure RTT on HTTP/S requests // This software is distributed AS IS and has no warranty. This is merely a learning exercise and should not be used in production under any circumstances. // This is my own work and not that of my employer, not is endorsed or supported by them in any conceiva...
package postgres import ( "chat/internal/chat" "database/sql" "fmt" "strconv" "github.com/lib/pq" "github.com/pkg/errors" ) var _ chat.Chats = &ChatStorage{} // RobotStorage ... type ChatStorage struct { statementStorage createStmt *sql.Stmt createUCStmt *sql.Stmt findStmt *sql.Stmt } // NewRobot...
// SPDX-License-Identifier: MIT package lsp import ( "reflect" "github.com/caixw/apidoc/v7/core" "github.com/caixw/apidoc/v7/internal/ast" "github.com/caixw/apidoc/v7/internal/lsp/protocol" ) var ( referencerType = reflect.TypeOf((*ast.Referencer)(nil)).Elem() definitionerType = reflect.TypeOf((*ast.Definit...
package lambda import ( "context" "fmt" "os" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3" "golang.org/x/sync/errgroup" "github.com/Clever/ci-scripts/internal/environment" ) // Lambda wraps s3 to provide a simple API building and publishing lambdas. type Lambda struct { awsCfg...
package controller import ( "context" "encoding/json" "errors" "github.com/ipfs/go-cid" storeError "github.com/kenlabs/pando-store/pkg/error" "github.com/kenlabs/pando-store/pkg/types/cbortypes" v1 "github.com/kenlabs/pando/pkg/api/v1" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo/opti...
// Copyright (C) 2023 Storj Labs, Inc. // See LICENSE for copying information package sync2_test import ( "sync/atomic" "testing" "github.com/stretchr/testify/require" "storj.io/common/sync2" ) func TestGo(t *testing.T) { var a int32 wait := sync2.Go( func() { atomic.AddInt32(&a, 1) }, func() { atomic.Ad...
package prompt import ( "github.com/google/wire" ) var WireSet = wire.NewSet( NewTerminalPrompt, wire.Value(OpenInput(TTYOpen)))
package main import "fmt" func soma(numeros ...int) int { somatoria := 0 for _, n := range numeros { somatoria += n } return somatoria } func main() { fmt.Println(soma(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) }
package raftkv import "github.com/6.824/labrpc" import "crypto/rand" import "math/big" type RetryState int const ( DontRetry RetryState = iota RetryWithNewIndex RetryWithOldIndex ) type Clerk struct { servers []*labrpc.ClientEnd // You will have to modify this struct. serverCount int maxRetryTime int32 } f...
package main import ( "github.com/gorilla/websocket" "log" "net/http" ) const ( ReadBufferSize = 1024 WriteBufferSize = 1024 ) type Server struct { Address string connLimit int conns chan struct{} Http *http.Server } func NewServer(address string) *Server { s := &Server{ Address: address, Http:...
/* * Neblio REST API Suite * * APIs for Interacting with NTP1 Tokens & The Neblio Blockchain * * API version: 1.3.0 * Generated by: OpenAPI Generator (https://openapi-generator.tech) */ package neblioapi type IssueTokenResponse struct { // TokenId of the to be issued token TokenId string `json:"tokenId,omite...
package apiControllers import "github.com/gin-gonic/gin" func broadvidadsFlushAdCache(c *gin.Context) {}
package main import ( "fmt" "math" ) /* Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these m subarrays. Note: If n is the length of array, assume the following const...
package protectionruns import( "errors" "fmt" "encoding/json" "github.com/cohesity/management-sdk-go/models" "github.com/cohesity/management-sdk-go/unirest-go" "github.com/cohesity/management-sdk-go/apihelper" "github.com/cohesity/management-sdk-go/configuration" ) /* * Client structure as interf...
package distro_test import ( "testing" "github.com/stretchr/testify/require" "github.com/osbuild/osbuild-composer/internal/distro" "github.com/osbuild/osbuild-composer/internal/distro/distro_test_common" "github.com/osbuild/osbuild-composer/internal/distro/fedora31" "github.com/osbuild/osbuild-composer/interna...
package timingwheel_test import ( "fmt" "time" "github.com/EagleChen/timingwheel" ) func ExampleTimingWheel() { tw := timingwheel.NewWheelTimer() tw.Start() done := make(chan struct{}) if err := tw.Add(time.Now().UnixNano()/1000000+1, func() { fmt.Println("hello world") done <- struct{}{} }); err != nil...
package helpers import ( "encoding/json" "fmt" "reflect" "strings" ) func ToLiteralForJS(input interface{}) string { switch t := input.(type) { case bool, int, int8, int16, int32, int64, float32, float64: return fmt.Sprintf("%v", t) case string: return fmt.Sprintf("\"%s\"", t) } switch reflect.TypeOf(inp...
package login_psql import ( "context" "database/sql" "errors" "github.com/lib/pq" "github.com/overmesgit/awesomeSql/login" "github.com/overmesgit/awesomeSql/login_psql/models" "github.com/volatiletech/null/v8" "github.com/volatiletech/sqlboiler/v4/boil" ) type PSQLStorage struct { db *sql.DB } func NewPSQLS...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package fingerprint import "testing" func TestEncryptionStatusEctoolUnmarshalerTPMSeed(t *testing.T) { // It should not matter that there are tabs to the left of the examp...
package util import ( "crypto/rand" "crypto/rsa" "crypto/x509" "encoding/base64" "encoding/json" "encoding/pem" "errors" "github.com/yuwe1/pgim/pkg/logger" ) // token信息 type TokenInfo struct { AppId int64 `json:"app_id"` UserId int64 `json:"user_id"` DeviceId int64 `json:"device_id"` Expire int64 ...
package types // NodeConnectOptions are options for configuring a connection to a remote node. type NodeConnectOptions struct { // The user to attempt to SSH into the remote node as. SSHUser string // A password to use for SSH authentication. SSHPassword string // The path to the key to use for SSH authentication...
// Copyright 2021 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package graphics import ( "context" "os" "path/filepath" "time" "chromiumos/tast/common/testexec" "chromiumos/tast/local/graphics/expectations" "chromiumos/tast/loca...
package _7_throughTheFog import "fmt" func main() { deposit := 100 rate := 20 threshold := 170 result := depositProfit(deposit, rate, threshold) fmt.Println(result) } func depositProfit(deposit int, rate int, threshold int) int { years := 0 total := float64(deposit) for total < float64(threshold) { year...
package models import( "encoding/json" ) /** * Type definition for Type30Enum enum */ type Type30Enum int /** * Value collection for Type30Enum enum */ const ( Type30_KRECOVERVMS Type30Enum = 1 + iota Type30_KMOUNTVOLUMES ) func (r Type30Enum) MarshalJSON() ([]byte, error) { ...
package main import ( "fmt" ) func main() { // var intArr = [...]int8 {10, 20, 30, 21} // fmt.Printf("%p\n", &intArr[1]) // slice := intArr[1:3] // fmt.Printf("%p\n", &slice[0]) // //fmt.Printf("%p\n", slice) // fmt.Println(cap(slice)) // slice = append(slice, 22) // slice = append(slice, 23) // fmt.Println...
package user import ( "go.mongodb.org/mongo-driver/bson/primitive" "yes-blog/graph/model" "yes-blog/internal/model/post" ) type User struct { ID primitive.ObjectID `bson:"_id" json:"id,omitempty"` Name string Password string Email string Admin bool Posts []*post.Post } func NewUser(name, ...
/* Copyright 2020 The Knative 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, soft...
package main import ( "bufio" "io/ioutil" "log" "os" "strings" ) func readBytesFromFile() []byte { targetSrcFile := os.Args[1] content, err := ioutil.ReadFile(targetSrcFile) if err != nil { log.Fatal(err) } return content } func readBytesFromPipe() []byte { reader := bufio.NewReader(os.Stdin) content, ...
// Package msgpack provides a codec for encoding and decoding data using msgpack. package msgpack import ( "github.com/achilleasa/usrv/encoding" impl "gopkg.in/vmihailenco/msgpack.v2" ) type msgpackCodec struct{} func (c *msgpackCodec) Marshaler() encoding.Marshaler { return func(v interface{}) ([]byte, error) { ...
package aws import ( "github.com/cyberark/secretless-broker/pkg/secretless/plugin/connector" "github.com/cyberark/secretless-broker/pkg/secretless/plugin/connector/http" ) // PluginInfo is required as part of the Secretless plugin spec. It provides // important metadata about the plugin. func PluginInfo() map[strin...
/* @File: model.go @Contact: lucien@lucien.ink @Licence: (C)Copyright 2019 Lucien Shui @Modify Time @Author @Version @Description ------------ ------- -------- ----------- 2019-07-25 01:39 Lucien 1.0 Init */ package model import ( "github.com/jinzhu/gorm" _ "github.com/mattn/go-sq...
package main import ( "fmt" "os" "os/exec" "strings" ) // This is a meta-linter to help code quality high. // It runs several linters and shows the result. // It applies filters over the results because otherwise // there's too much noise. // List of possible linters: https://github.com/alecthomas/gometalinter#su...
package main import "fmt" /* Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too. You need to find the shortest such subarray and output its length. Example 1: Input: [2, 6, 4, 8, 10, 9, ...
package main import ( "os" "github.com/typical-go/typical-go/pkg/typgo" ) var descriptor = typgo.Descriptor{ ProjectName: "custom-task", ProjectVersion: "1.0.0", Environment: typgo.Environment{ "key1": "value1", "key2": "value2", }, Tasks: []typgo.Tasker{ // compile &typgo.GoBuild{}, // run &...
package main import "fmt" /* Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You may not modify the values in the list's nodes, only nodes itself may be changed. Example 1: Given 1->2->3->4, reorder it to 1->4->2->3. Example 2: Given 1->2->3->4->5, reorder it to 1->5->2->4->3...
package watcher import ( "time" "github.com/MagalixTechnologies/uuid-go" ) const ( // DefaultEventsOrigin default origin when not specified DefaultEventsOrigin = "watcher" ) // Event structure type Event struct { ID interface{} `json:"id,omitempty" bson:"id,omitempty"` Timestamp time.Time `js...
package httpexpect import ( "testing" "time" "github.com/stretchr/testify/assert" ) func TestStringFailed(t *testing.T) { chain := makeChain(newMockReporter(t)) chain.fail("fail") value := &String{chain, ""} value.Path("$").chain.assertFailed(t) value.Schema("") value.DateTime() value.Empty() value.No...
/* 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 law or agreed to in w...
package models import ( "encoding/json" // "github.com/elgs/gosqljson" "log" // "strings" ) type MerchantCategory struct { Id int64 `form:"id"` Merchant_category_name string `form:"merchant_category_name"` Slug string `form:"slug"` Create_at int64 `form:"cr...
/** 顺序栈实现游览器前进,后退功能 */ package stack import "fmt" const MAXNUM = 2 func main() { sb := newStackBrower() sb.visit("a") sb.visit("b") // sb.visit("c") sb.backward() sb.backward() sb.foreward() sb.visit("d") } func newStackBrower() *stackBrowser { return &stackBrowser{ sfore: newStackA("fore", MAXNUM), sb...
package main import "fmt" func main() { s := []int{9, 2, 3, 1, 4, 7, 5, 6, 0, 8} res := make([]int, len(s)) mergeSortRecursive(s, res, 0, len(s)-1) } func mergeSortRecursive(s, result []int, left, right int) { if left == right { return } middle := (left + right) / 2 mergeSortRecursive(s, result, left, mid...
package main type Todo struct { Id int `json:"id"` Title string `json:"title"` Position int `json:"position"` Complete bool `json:"complete"` }
package abkzeromq import ( "fmt" "strings" zmq "github.com/alecthomas/gozmq" ) type READ func(key string) string type PUSH func(key string, val string) bool func ZmqRep(req_port int, rep_port int, read READ, push PUSH) { context, _ := zmq.NewContext() socket, _ := context.NewSocket(zmq.REP) socket.Bind(f...
package coinzilla import ( "encoding/json" "fmt" "net/http" "github.com/prebid/openrtb/v19/openrtb2" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/errortypes" ) func Builder(bidderName openrt...
package main import ( "bufio" "encoding/json" "fmt" "log" "net/http" "net/url" "regexp" "runtime" "strings" "time" "github.com/iand/feedparser" "github.com/koding/cache" "html/template" "sevki.org/lib/prettyprint" ) var ( httpCache *cache.MemoryTTL ) func init() { httpCache = cache.NewMemoryWithTT...
package main import "fmt" var x int func main() { x = 10 fmt.Printf("%v, %T", x, x) }