text
stringlengths
11
4.05M
func peakIndexInMountainArray(A []int) int { for i:=0;i<len(A);i++{ if A[i+1]<A[i] && A[i-1]<A[i]{ return i } } return 0 }
package freshbooks import ( "bytes" "encoding/xml" "io/ioutil" "net/http" "os" ) type Request struct { XMLName xml.Name `xml:"request"` Method string `xml:"method,attr"` } func Do(request interface{}) ([]byte, error) { api := os.Getenv("FRESHBOOKS_API_URL") apiKey := os.Getenv("AUTHENTICATION_TOKEN") c...
package main import ( "encoding/json" "fmt" ) type matrix struct{ rows int cols int elements [][]int } func (m matrix) numberOfRows() int{ return m.rows } func (m matrix) numberOfCols() int{ return m.cols } func (m matrix) setElements(i,j,element int){ m.elements[i][j]=element } func (m *matrix) printM...
package usecase import ( "github.com/taniwhy/mochi-match-rest/domain/models" "github.com/taniwhy/mochi-match-rest/domain/repository" ) // GameTitleUseCase : type GameTitleUseCase interface { FindAllGameTitle() ([]*models.GameTitle, error) InsertGameTitle(gameTitle *models.GameTitle) error UpdateGameTitle(gameTit...
package models import "errors" var ( //ErrSnapshotNotFound used when snapshot is not found ErrSnapshotNotFound = errors.New("not found") ) // Snapshot represents specific version of protodescriptorset type Snapshot struct { ID int64 `binding:"required"` Namespace string `binding:"required"` Name st...
package dropbox import ( "bufio" "bytes" "github.com/container-storage-interface/spec/lib/go/csi" "github.com/golang/glog" "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "k8s.io/utils/mount" "os" "os/exec" "path" "strings" ) type nodeServer struct { nodeID strin...
package main type User struct { Name string } func main() { u := User{Name: "Leto"} println(u.Name) Modify(u) println(u.Name) arr := []int{} println(arr) M(&arr) println(arr) } func Modify(u User) { u.Name = "Duncan" } func M(arr *[]int) { *arr = append(*arr, 1) }
// Copyright 2019 Radiation Detection and Imaging (RDI), LLC // Use of this source code is governed by the BSD 3-clause // license that can be found in the LICENSE file. package data import ( "encoding/binary" "log" "github.com/rditech/rdi-live/model/rdi/currentmode" "github.com/proio-org/go-proio" ) func Asse...
package example import ( "log" "os" "syscall" "github.com/Beyond-simplechain/foundation/allocator/shmallocator" ) type Item struct { id uint32 name [4]byte //p *byte } const _TestMemorySize = 1024 * 1024 * 1024 * 4 const _TestMemoryFilePath = "/tmp/data/mmap.bin" var defaultAlloc = shmallocator.New(func()...
package handler import "time" const ( // TokenAvailableDuration 是用户登录后所获得登录凭证的有效期 TokenAvailableDuration = time.Hour * 24 )
// Copyright (c) 2016 Nicolas Martyanoff <khaelin@gmail.com> // // Permission to use, copy, modify, and distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies. // // THE SOFTWARE IS PROVIDED "AS IS" A...
package dao import ( "database/sql" "errors" "fmt" _ "github.com/go-sql-driver/mysql" xerrors "github.com/pkg/errors" "geektime/Go-000/Week02/model" ) const ( MYSQLSRC = "root:123456@tcp(192.168.141.181:3306)/testdb?charset=utf8" ) var ( db *sql.DB ErrDaoNotFound = errors.New("Dao:No rows foun...
package userstorage import ( "crypto/md5" "encoding/hex" "errors" "fmt" "io/ioutil" "math/rand" "os" "strconv" "strings" ) // ErrWrongPassword : f var ErrWrongPassword error = errors.New("wrong password") // ErrWrongLoginOrPassword : u var ErrWrongLoginOrPassword error = errors.New("wrong login or password"...
package slack import ( "encoding/json" "fmt" "testing" "github.com/stretchr/testify/assert" ) var simpleMessage = `{ "type": "message", "channel": "C2147483705", "user": "U2147483697", "text": "Hello world", "ts": "1355517523.000005" }` func unmarshalMessage(j string) (*Message, error) { me...
package http import ( "github.com/asppj/droneDeploy/conf" "github.com/kataras/iris/v12" ) type ( request struct { Firstname string `json:"firstname"` Lastname string `json:"lastname"` } response struct { ID uint64 `json:"id"` // id Message string `json:"message"` // msg Platform string ...
package utils import ( "crypto/rand" "encoding/base64" "fmt" "time" "golang.org/x/crypto/bcrypt" ) // GenerateHash hash strings func GenerateHash(raw string) (string, error) { hash, err := bcrypt.GenerateFromPassword([]byte(raw), bcrypt.DefaultCost) if err != nil { return "", err } return string(hash), ni...
package usecase import ( "context" "go.uber.org/zap" "github.com/silverspase/todo/internal/modules/auth" "github.com/silverspase/todo/internal/modules/auth/model" ) type useCase struct { repo auth.Repository logger *zap.Logger } func NewUseCase(logger *zap.Logger, repo auth.Repository) auth.UseCase { retu...
package main type Problem15A struct { } func (this *Problem15A) Solve() { Log.Info("Problem 15A solver beginning!") system := DiskSlotSystem{}; err := system.Load("source-data/input-day-15a.txt"); if(err != nil){ Log.FatalError(err); } time := 0; for{ if(system.Simulate(time)){ Log.Info("First valid t...
// Copyright 2019 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
package main import ( "log" "net/http" "strings" "github.com/yanpozka/checkers/store" ) func gameWS(w http.ResponseWriter, r *http.Request) { parts := strings.Split(r.URL.Path, "/") gameID := parts[len(parts)-1] if gameID == "" { http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) re...
package main import ( "fmt" "github.com/gorilla/websocket" ) type ( MsgData struct { Dst string Data string Src string } PoolUnit struct { bus chan<- []byte out chan []byte } ) func (r *MsgData) Str() string { return fmt.Sprint("dst:", r.Dst, "data:", r.Data) } func NewPoolUnit(bus chan []byte) ...
package models type Post struct { ID int `json:"id"` Author_id int `json:"author_id,omitempty"` Author *string `json:"author"` Forum_id int `json:"forum_id,omitempty"` Forum *string `json:"forum"` Thread int `json:"thread"` Thread_nickname string `json:"thread_s...
package gost512 import ( "bufio" "bytes" "fmt" "os" "strings" gkeys "github.com/number571/go-cryptopro/gost_r_34_10_2012" "github.com/number571/tendermint/crypto" "github.com/number571/tendermint/crypto/tmhash" tmjson "github.com/number571/tendermint/libs/json" ) //------------------------------------- va...
package main import "fmt" func max(a, b int) int { if a > b { return a } return b } func rob(nums []int) int { if len(nums) == 0 { return 0 } maxLoot := nums[0] for i, _ := range nums { if i == 0 { continue } j := i - 2 k := i - 3 if j >= 0 { if k >= 0 { nums[i] = max(nums[i]+nums...
package docker import ( "fmt" "github.com/Sirupsen/logrus" dockerClient "github.com/fsouza/go-dockerclient" "sync" "time" ) const ( iamLabel = "com.swipely.iam-docker.iam-profile" iamExternalIdLabel = "com.swipely.iam-docker.iam-externalid" iamEnvironmentVariable ...
/* Take an input, and convert it from Two's Complement notation (binary where the first bit is negated, but the rest are taken as normal) into decimal. Input can be as a string, a list of digits, a number, or pretty much any other format which is recognizably Two's Complement. Leading zeroes must function properly. E...
package main import ( "fmt" ) func main() { sliceInt := []int{11, 2, 19, 220, 31, 5, 65, 70, 100} find := 65 fmt.Println(sliceInt) if len((sliceInt)) == 0 || (sliceInt)[0] == find { fmt.Println(sliceInt) return } if (sliceInt)[len(sliceInt)-1] == find { (sliceInt) = append([]int{find}, (sliceInt)[:len(sl...
// 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 writing...
package imageProcessingService import ( "bytes" "encoding/json" "errors" "fmt" "log" "net/http" ) func (client *ImageProcessingClient) ProcessPlate(data interface{}) error { log.Println("Sending ", fmt.Sprint(data)+" to image processing service...") reqBody, err := json.Marshal(data) if err != nil { print(...
package job import ( "context" "os" "github.com/sherifabdlnaby/prism/pkg/payload" "github.com/sherifabdlnaby/prism/pkg/response" ) // Job represent a job containing a streamable payload (the message) and a response channel, // which is used to indicate whether the payload was successfully processed and propagate...
package order type PaymentSessionUpdateReq struct { PaymentSessionId int64 AmountPaid float64 AmountLeft float64 Status string } type PaymentItemUpdateReq struct { PaymentItemId int64 `json:"paymentItemId"` PaymentSessionId int64 `json:"paymentSessionId"` Status string `jso...
package resolver import ( "github.com/taktakty/netlabi/testdata" "github.com/stretchr/testify/require" "strings" "testing" ) func TestIpSegmentQueries(t *testing.T) { testData := ipSegmentTestData t.Run("GetSingle", func(t *testing.T) { p := string(testData[0].ID) q := strings.Join([]string{`query {getIpSe...
package otf import "io" type SubtableReader struct { io.ReadSeeker } func (t *SubtableReader) Size() int64 { n, err := t.Seek(0, 2) if err != nil { return 0 } return n } func (t *SubtableReader) Bytes() []byte { bytes := make([]byte, t.Size()) t.Seek(0, 0) t.Read(bytes) return bytes }
/* Description Your rich uncle died recently, and the heritage needs to be divided among your relatives and the church (your uncle insisted in his will that the church must get something). There are N relatives (N <= 18) that were mentioned in the will. They are sorted in descending order according to their importanc...
// ˅ package main import ( "github.com/lxn/walk" ) // ˄ type ColleagueButton struct { // ˅ // ˄ Colleague pushButton *walk.PushButton // ˅ // ˄ } func NewColleagueButton(pushButton *walk.PushButton) *ColleagueButton { // ˅ colleagueButton := &ColleagueButton{} colleagueButton.Colleague = *NewColleagu...
package scanner import ( "time" ) const ( // AnalysisStatusQueued denotes a request for analysis has been // accepted and queued AnalysisStatusQueued = "queued" // AnalysisStatusErrored denotes a request for analysis has errored during // the run, the message field will have more details AnalysisStatusErrored ...
package camt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document02600101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:camt.026.001.01 Document"` Message *UnableToApply `xml:"camt.026.001.01"` } func (d *Document02600101) AddMessage() *UnableToA...
package types // OrderFill represents a filled trade of an order // And order can have multiple fill's before being completely // executed type OrderFill struct { // Price of the fill Price float64 // Quantity filled (in base asset) Quantity float64 // Commission payed Commission float64 // Asset in which th...
package weight_validation type validation struct { } func NewValidation() *validation { return &validation{} } func (v *validation) GetMessage() map[string]string { return map[string]string { "Number.required": "請輸入體重資料", } } type GetUpdateRule struct { Number float32 `json:"number" form:"number" binding:"r...
package aggregates import ( "github.com/tmtx/res-sys/app" "github.com/tmtx/res-sys/pkg/bus" "github.com/tmtx/res-sys/pkg/event" "github.com/tmtx/res-sys/pkg/validator" ) type User struct { Base Email string `bson:"email"` HashedPassword string `bson:"hashed_password"` } func (ag *User) GetTargetEvent...
package main import ( "SoftwareGoDay2/routes" "SoftwareGoDay2/server" "fmt" ) func main() { s := server.NewServer() routes.ApplyRoutes(s.Router) err := s.Router.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080") if err != nil { fmt.Println(err) } }
package polynomial import "math/big" var LInt = new(big.Int).SetBytes([]byte{0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0xde, 0xf9, 0xde, 0xa2, 0xf7, 0x9c, 0xd6, 0x58, 0x12, 0x63, 0x1a, 0x5c, 0xf5, 0xd3, 0xed})
package controllers import ( "context" "strings" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/util/intstr" gitifold "hyperspike.io/eng/gitifold/api/v1beta1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/api/...
package engine import ( "golang.org/x/exp/shiny/driver" "golang.org/x/exp/shiny/screen" "golang.org/x/mobile/event/key" "golang.org/x/mobile/event/lifecycle" "io" "log" "sync" "time" "image" "image/color" "image/draw" _ "image/gif" _ "image/jpeg" _ "image/png" ) // State is the main struct of the engin...
package snet import ( "io" ) type rewriter struct { data []byte begin int } func (r *rewriter) Push(b []byte) { /* if len(b) >= len(r.data) { copy(r.data, b[len(b)-len(r.data):]) } else { copy(r.data, r.data[len(b):]) copy(r.data[len(r.data)-len(b):], b) } */ for c, n := b, 0; len(c) > 0; c = c...
package models import ( "time" mgo "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" "github.com/ne7ermore/gRBAC/common" "github.com/ne7ermore/gRBAC/plugin" ) type Permission struct { Id bson.ObjectId `bson:"_id,omitempty" json:"id"` Name string `bson:"name" json:"name"` Descrip string ...
// 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 services import ( "interface-testing/api/domain/weather_domain" "interface-testing/api/providers/weather_provider" "net/http" "testing" "github.com/stretchr/testify/assert" ) var ( getWeatherProviderFunc func(request weather_domain.WeatherRequest) (*weather_domain.Weather, *weather_domain.WeatherError)...
package x // GENERATED BY XO. DO NOT EDIT. import ( "errors" "strings" //"time" "ms/sun/shared/helper" "strconv" "github.com/jmoiron/sqlx" ) // (shortname .TableNameGo "err" "res" "sqlstr" "db" "XOLog") -}}//(schema .Schema .Table.TableName) -}}// .TableNameGo}}// SettingNotifications represents a row from 'su...
package live import ( "backend/api" "backend/internal/fixture" simulator "backend/internal/simulation" "database/sql" "encoding/json" "github.com/gin-gonic/gin" "github.com/gorilla/websocket" "log" "time" ) var upgrader = websocket.Upgrader{} const timeScale float64 = 5.0/60.0 var ...
package rest import ( "github.com/HNB-ECO/HNB-Blockchain/HNB/appMgr" appComm "github.com/HNB-ECO/HNB-Blockchain/HNB/appMgr/common" "github.com/HNB-ECO/HNB-Blockchain/HNB/common" "github.com/HNB-ECO/HNB-Blockchain/HNB/config" "github.com/HNB-ECO/HNB-Blockchain/HNB/contract/hgs" "github.com/HNB-ECO/HNB-Blockchain/...
package cmd import ( "github.com/alewgbl/fdwctl/internal/config" "github.com/alewgbl/fdwctl/internal/database" "github.com/alewgbl/fdwctl/internal/logger" "github.com/alewgbl/fdwctl/internal/model" "github.com/alewgbl/fdwctl/internal/util" "github.com/spf13/cobra" "strings" ) const ( dropServerCmdMinArgCount ...
package main import (. "fmt" "runtime" "time" ."net" ) func checkError(err error) { if err != nil { Println("Feil %v", err) return } } func main() { runtime.GOMAXPROCS(runtime.NumCPU()) // limits num of threads to num of cores buffer := make([]byte, 1024) // make an array with size 1024*bytes udp_addr, ...
package main import ( "fmt" "math" "github.com/skorobogatov/input" ) type V struct { w int dist int x, y int } type PriorityQueue struct { heap []*V cnt int } func Less(pq *PriorityQueue, i, j int) bool { h := pq.heap return h[i].dist < h[j].dist } func Swap(pq *PriorityQueue, i, j int) { pq.heap[i...
package leetcode import "testing" func TestDetectCycle(t *testing.T) { l := &ListNode{} h := l for i := 1; i < 6; i++ { l.Val, l.Next = i, &ListNode{} l = l.Next } l.Next = h.Next s := detectCycle(h) if s == nil { t.Log("nil") } else { t.Log(s.Val) } }
package license import ( "encoding/base64" "encoding/json" "time" ) // Data is the data we expect in the license type Data struct { CustomerEmail string `json:"customer_email"` CreateTime time.Time `json:"create_time"` } // SetTime will load the current time into "data". Duration as -1 to remove // the mo...
// Copyright 2020 Clivern. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. package model import ( "fmt" "strings" "time" "github.com/clivern/walrus/core/driver" "github.com/clivern/walrus/core/util" log "github.com/sirupsen/logrus" "git...
package dbstorage import ( "context" "fmt" "strconv" "strings" "time" // init sql driver _ "github.com/jackc/pgx/stdlib" "github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx/reflectx" "github.com/pkg/errors" "github.com/andywow/golang-lessons/lesson-calendar/internal/calendar/config" "github.com/andywow/go...
// *** *** *** *** *** *** *** *** // signFind is a small backend utility/API to // serve media for SignFind Android/iOS App. // *** *** *** *** *** *** *** *** // Milla Says AS (C) 2017 // By Roy Dybing // github.com: rDybing // slack.com: rdybing // https://github.com/rDybing/SignF...
package connection import ( "bytes" "compress/zlib" "context" "crypto/sha256" "crypto/tls" "crypto/x509" "database/sql/driver" "encoding/hex" "encoding/json" "fmt" "io" "net/url" "strings" "github.com/exasol/exasol-driver-go/internal/utils" "github.com/exasol/exasol-driver-go/pkg/errors" "github.com/e...
// Copyright 2023 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
package lyft import ( "encoding/json" "fmt" "time" "golang.org/x/net/context" ) type PassengerDetail struct { FirstName string `json:"first_name"` LastName string `json:"last_name"` } type DriverDetail struct { FirstName string `json:"first_name"` PhoneNumber string `json:"phone_number"` Rating str...
package main import "fmt" import "time" func main() { jst, _ := time.LoadLocation("Asia/Tokyo") fmt.Println(time.Now().In(jst).Format("2006/01/02 15:04:05")) }
package public import ( "context" "time" "tpay_backend/merchantapi/internal/common" "tpay_backend/merchantapi/internal/svc" "tpay_backend/merchantapi/internal/types" "tpay_backend/model" "github.com/tal-tech/go-zero/core/logx" ) type HomeInfoLogic struct { logx.Logger ctx context.Context svcCtx *svc.Ser...
package v5 import ( "bytes" "context" "encoding/json" "fmt" "github.com/elastic/go-elasticsearch/v5" "io/ioutil" ) type Elastic struct { client *elasticsearch.Client index string } func New(address string, index string) *Elastic { client, _ := elasticsearch.NewClient(elasticsearch.Config{ Addresses: []s...
package main import ( "testing" ) func TestClean(t *testing.T) { for _, test := range []struct { input string expected string err bool }{ { "", "", false, }, { `*.c `, `*.c `, false, }, { `*.c ` + delimiterStart + `executable ` + delimiterEnd, `*.c `, false, }, ...
package response import ( "KServer/manage" "KServer/proto" "fmt" ) type ClientResponse struct { IManage manage.IManage } func NewClientResponse(m manage.IManage) *ClientResponse { return &ClientResponse{IManage: m} } // 用于接收客户端主题 func (c *ClientResponse) ResponseClient(data proto.IDataPack) { fmt.Println("收到...
package requests type WalletContainsRequest struct { BaseRequest `mapstructure:",squash"` Account string `json:"account" mapstructure:"account"` }
package operations import ( "strings" "sync" "time" ) type order struct { Timestamp int64 `json:"timestamp"` Operation string `json:"operation"` IssuerName string `json:"IssuerName"` TotalShares int `json:"TotalShares"` SharePrice int `json:"SharePrice"` } type issuer struct { IssuerName strin...
/* 2019-4-24: 程序主入口 花花CMS是一个内容管理系统,代码尽可能地补充必要注释,方便后人协作 **/ package main import ( "flag" "github.com/hunterhug/fafacms/core/config" "github.com/hunterhug/fafacms/core/controllers" "github.com/hunterhug/fafacms/core/flog" "github.com/hunterhug/fafacms/core/model" "github.com/hunterhug/fafacms/core/router" ...
package service import ( "errors" "fmt" "io/ioutil" "log" "net/http" "github.com/binjamil/keyd/core" "github.com/binjamil/keyd/transact" "github.com/gorilla/mux" ) var TransactionLogger transact.TransactionLogger func GetHandler(rw http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) key := vars["k...
// +build !qml package view import ( "github.com/therecipe/qt/widgets" "github.com/therecipe/qt/internal/examples/sql/masterdetail_qml/controller" "github.com/therecipe/qt/internal/examples/sql/masterdetail_qml/view/album" "github.com/therecipe/qt/internal/examples/sql/masterdetail_qml/view/artist" ...
package LICY_BLC import "fmt" func (cli *Licy_CLI) licy_createWallet(){ wallets ,_:=Licy_ReadWallets() wallets.Licy_CreateNewWallet() fmt.Println(len(wallets.Licy_WalletsMap)) }
package iptool import ( "fmt" "regexp" "testing" ) func TestSearchIPFail(t *testing.T) { err := SearchIP("192.168.2.2") if err == nil { t.Log(err) t.Fail() } } func TestSearchIPSucess(t *testing.T) { err := SearchIP("www.suncco.com") if err != nil { t.Log(err) t.Fail() } } func TestParseIpsOne(t *t...
// Copyright (C) 2018 Storj Labs, Inc. // See LICENSE for copying information. package boltdb import ( "time" "github.com/boltdb/bolt" "go.uber.org/zap" ) var ( defaultTimeout = 1 * time.Second ) const ( // fileMode sets permissions so owner can read and write fileMode = 0600 ) // Client is the storage inte...
package leetcode /*Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target. 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/two-sum-iv-input-is-a-bst 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。*/ /** * Definition for a binary tre...
package main import ( "fmt" ) func main() { a := make([]int, 6) for i := 0; i < 6; i++ { a[i] = i } b := append(a[:2], a[3:]...) fmt.Print(b) }
/* You are given an array of integers nums. You are also given an integer original which is the first number that needs to be searched for in nums. You then do the following steps: If original is found in nums, multiply it by two (i.e., set original = 2 * original). Otherwise, stop the process. Repeat this process w...
package request import "github.com/agusbasari29/Skilltest-RSP-Akselerasi-2-Backend-Agus-Basari/entity" type RequestUser struct { ID uint `json:"id"` Username string `json:"username" validate:"required,alphanum"` Fullname string `json:"fullname" validate:"required"` Email stri...
package gen import ( "bytes" "errors" "fmt" "io" "io/ioutil" "os" "os/exec" "path/filepath" "sort" "strings" "unicode" // "github.com/vugu/vugu/internal/htmlx" // "github.com/vugu/vugu/internal/htmlx/atom" // "golang.org/x/net/html" // "golang.org/x/net/html/atom" "github.com/vugu/html" "github.com/v...
package floc import "fmt" // ResultSet is the set of possible results. This set is the simple // implementation of Set with no check for duplicate values and it covers only // basic needs of floc. type ResultSet []Result // NewResultSet constructs the set with given results. The function validates // all result valu...
package workers_test import ( "encoding/json" "fmt" "github.com/APTrust/exchange/constants" "github.com/APTrust/exchange/models" "github.com/APTrust/exchange/network" "github.com/APTrust/exchange/util/testutil" "github.com/APTrust/exchange/workers" "github.com/stretchr/testify/assert" "github.com/stretchr/tes...
package utils import ( "fmt" "os" "sort" "strconv" "strings" ) const sourceCodeUrl = "https://github.com/mingchoi/LeetCode-Solution/blob/master/" const markdownReportHeader = `# LeetCode Solution Solutions are written in Golang or Java. Here are the result: (higher is better, max at 100) ` type Result stru...
// program subscribes and listens to the nanomsg stream publiched by the Wasp host // and displays it in the console package main import ( "fmt" "github.com/iotaledger/wasp/packages/subscribe" "os" "os/signal" "strings" "sync" "syscall" ) func main() { if len(os.Args) != 2 { fmt.Printf("Usage: submsg <pub h...
package main import ( "bytes" "errors" "flag" "net" "net/http" "strings" "crypto/aes" "crypto/cipher" "encoding/base64" "encoding/json" "github.com/ssoor/socks" ) func Decrypt(base64Code []byte) (decode []byte, err error) { type encodeStruct struct { IV string `json:"iv"` Code...
package model type DashWebmRepresentation struct { // Id of the resource Id string `json:"id,omitempty"` // UUID of an encoding EncodingId string `json:"encodingId,omitempty"` // UUID of a muxing MuxingId string `json:"muxingId,omitempty"` Type DashRepresentationType `json:"type,omitempty"` Mode DashRepresenta...
package server import ( "api/entities" "api/utils" routing "github.com/qiangxue/fasthttp-routing" ) // GetCurrentUser ... func (s *Server) GetCurrentUser() routing.Handler { return func(c *routing.Context) error { user, ok := c.Get("user").(*entities.User) if !ok { return utils.Respond(c, 401, map[string]...
package baikal type MinerStats struct { Devs []SGDev Pools []SGPool Stats []SGStat Summary SGSummary System MinerStatsSystem } type MinerStatsSystem struct { TempCPU string }
/* 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 whole. It will appea...
package repository import ( "fmt" "github.com/jinzhu/gorm" "log" "time" ) type ExchangeRateData struct { ID int64 ExchangeRateID int64 Rate float64 ValidTime time.Time } type RateDataRepositoryItf interface { InsertDailyExchangeRateData(*ExchangeRate, *ExchangeRateData) error Get...
package core import ( "strings" "time" ) type dbType string type Uri struct { DbType dbType Proto string Host string Port string DbName string User string Passwd string Charset string Laddr string Raddr string Timeout time.Duration } // a dialect is a driver's wrapper type Dialect int...
package fateRPGtest import ( "testing" "github.com/faterpg" ) func TestNewConsequence(t *testing.T) { var con *faterpg.Consequence con = faterpg.NewConsequence() if con == nil { t.Error("NewConsequence return nil") } } func TestConsequenceAttr(t *testing.T) { con := faterpg.NewConsequence() con.Name = "Te...
package main import ( "fmt" "os" cli "gx/ipfs/QmckeQ2zrYLAXoSHYTGn5BDdb22BqbUoHEHm8KZ9YWRxd1/iptb/cli" testbed "gx/ipfs/QmckeQ2zrYLAXoSHYTGn5BDdb22BqbUoHEHm8KZ9YWRxd1/iptb/testbed" browser "gx/ipfs/QmXZuSpcGSesFXDWwZnESp2YEcYNcR4em9P86XsZtcuzWR/iptb-plugins/browser" docker "gx/ipfs/QmXZuSpcGSesFXDWwZnESp2YEcYN...
package map_test import ( "fmt" ) func ExampleArray() { a := [3]int{1, 2, 3} b := [10]int{1, 2, 3} c := [...]int{1, 2, 3} fmt.Println(a) fmt.Println(b) fmt.Println(c) // Output: // [1 2 3] // [1 2 3 0 0 0 0 0 0 0] // [1 2 3] } func ExampleSlice() { s1 := []int{1, 2, 3} s2 := make([]int, 3) fmt.Println(...
package kubeconfig import ( "encoding/base64" "net/http" "os" "strings" "time" "github.com/pkg/errors" "k8s.io/client-go/plugin/pkg/client/auth/exec" restclient "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/transport" ) const ( BasicAuthScheme = "Basic" BearerAuthScheme =...
package retry import "fmt" func StopRetryWithError(err error) error { if err == nil { return nil } return stopRetryError{originError: err} } type stopRetryError struct { originError error } func (err stopRetryError) Error() string { return fmt.Sprintf("stop retry with error: %s", err.originError) }
package main import "fmt" type A interface { Yuwen() } type B interface { English() } type nil interface { // 空接口可以被任何类型都实现,所以可以把任意变量都赋给他~ } type exams interface { // 要想继承A和B的接口~ 那么就需要全部实现A和B中的所有方法~~~ A B score() } type student struct { } func (stu student) Yuwen() { fmt.Println("参加语文考试中~~~~") } func (stu ...
package runtime import ( "fmt" "sync" ) type waitQueue struct { lock sync.Mutex queue []*GoRoutine } func NewWaitQueue() *waitQueue { return &waitQueue{ queue: make([]*GoRoutine, 0), } } func (q *waitQueue) add(g *GoRoutine) { q.lock.Lock() defer q.lock.Unlock() g.Block() fmt.Printf("[Block Queue] Goro...
package goSolution /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func sortedArrayToBST(nums []int) *TreeNode { if len(nums) == 0 { return nil } if len(nums) == 1 { return &TreeNode{Val: nums[0]} } l, r := 0, len(nums) ...
package historian import ( "bytes" "errors" "time" "github.com/fuserobotics/historian/dbproto" "github.com/fuserobotics/statestream" "github.com/golang/glog" r "gopkg.in/dancannon/gorethink.v2" ) var changeUnnecessaryError error = errors.New("change applied locally already") type Stream struct { dispose cha...