text
stringlengths
11
4.05M
package cache import ( "encoding/json" "project/app/admin/models/bo" "project/common/global" "strconv" ) const ( DeptIdKeyFore = "dept::id:" DeptPidKeyFore = "dept::pid:" ) // dept::pid:{number} 设置子部门缓存 func SetRedisDeptByPid(pid int, value interface{}) error { data, err := json.Marshal(value) if err != nil...
package osbuild1 import ( "testing" "github.com/stretchr/testify/assert" ) func TestNewRPMStage(t *testing.T) { expectedStage := &Stage{ Name: "org.osbuild.rpm", Options: &RPMStageOptions{}, } actualStage := NewRPMStage(&RPMStageOptions{}) assert.Equal(t, expectedStage, actualStage) }
package exception import "errors" var ( //repo RepoNotUpdate = errors.New("Fail to update infomation") RepoNotFound = errors.New("Repo not exist") RepoConlict = errors.New("Repo has exist") RepoInsertFail = errors.New("Fail to add Repo") //bookmark BookmarkNotFound = errors.New("Bookmark not exist") Bookm...
package ghclient import "context" // FakeRepoClient is fake implementaiton of RepoClient that runs user-supplied functions for each method type FakeRepoClient struct { GetBranchFunc func(context.Context, string, string) (BranchInfo, error) GetBranchesFunc func(context.Context, string) ...
package main // Add opportunity to show and add new blocks with html forms import ( "bytes" "crypto/sha256" "encoding/json" "fmt" "net/http" "strconv" "time" ) type Block struct { Timestamp int64 // date when block is created Data []byte // transactions or smartcontract PrevBlockhash []byte H...
package main import ( "github.com/rjeczalik/notify" "log" ) func main() { var must = func(err error) { if err != nil { log.Fatal(err) } } var stop = func(c ...chan<- notify.EventInfo) { for _, c := range c { notify.Stop(c) } } // Make the channels buffered to ensure no event is dropped. Notify w...
package crawl import "fmt" func Day_collection_name(id string) string { return fmt.Sprintf("%s.tdata.kday", id) }
package storage import "context" // Item represents an item at // a shop type Item struct { Name string Price int64 } // Storage is our storage interface // We'll implement it with Mongo // storage type Storage interface { GetByName(context.Context, string) (*Item, error) Put(context.Context, *Item) error }
package game_map import "github.com/faiface/pixel/pixelgl" type NonBlockingTimer struct { Seconds float64 ApplyFunc func(e *NonBlockingTimer) HasPopOut bool } func NonBlockingTimerCreate(seconds float64, applyFunc func(e *NonBlockingTimer)) *NonBlockingTimer { return &NonBlockingTimer{ Seconds: seconds, ...
package problem0871 import "testing" func TestSplve(t *testing.T) { t.Log(minRefuelStopsII(1, 1, [][]int{})) t.Log(minRefuelStopsII(100, 1, [][]int{[]int{10, 100}})) t.Log(minRefuelStopsII(100, 10, [][]int{[]int{10, 60}, []int{20, 30}, []int{30, 30}, []int{60, 40}})) }
package server import ( "crypto/sha256" "html/template" "path/filepath" "time" "github.com/gin-contrib/multitemplate" "github.com/gin-gonic/contrib/sessions" "github.com/gin-gonic/gin" "github.com/go-webpack/webpack" "github.com/sirupsen/logrus" ginlogrus "github.com/toorop/gin-logrus" // TODO: Fixme "git...
package main import ( "runtime" "strings" "github.com/GoAdminGroup/go-admin/modules/auth" "github.com/GoAdminGroup/go-admin/modules/db" "github.com/GoAdminGroup/go-admin/modules/db/dialect" "gopkg.in/ini.v1" ) func addUser(cfgFile string) { clear(runtime.GOOS) cliInfo() var ( driverName, host, port, dbF...
package validate import ( "fmt" "reflect" "time" ) // DataFace interface definition type DataFace interface { Type() uint8 Get(key string) (interface{}, bool) Set(field string, val interface{}) error // validation instance create func Create(err ...error) *Validation Validation(err ...error) *Validation } v...
package gomobile import ( "crypto/sha256" "encoding/hex" "encoding/json" "fmt" "math" "strconv" "incognito-chain/common" "incognito-chain/key/incognitokey" "incognito-chain/key/wallet" "incognito-chain/privacy" "incognito-chain/privacy/blsmultisig" "incognito-chain/privacy/privacy_v1/hybridencryption" tr...
package helpers import "log" func CheckError(err error) { if err != nil { log.Println(err.Error()) } }
package gotime import ( "fmt" "time" ) func NowTime() string { return time.Now().Format("2006-01-02 15:04:05") } func TimeBefore(time1,time2 string) bool { t1, err := time.Parse("2006-01-02 15:04:05", time1) t2, err := time.Parse("2006-01-02 15:04:05", time2) if err == nil && t1.Before(t2) { //处理逻辑 return ...
package sese import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document03700204 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.037.002.04 Document"` Message *PortfolioTransferNotification002V04 `xml:"PrtflTrfNtfctn"` } func (d...
package cmd import ( "fmt" "github.com/spf13/cobra" ) // versionCmd represents the version command var versionCmd = &cobra.Command{ Use: "version", Short: "Display version information", Long: `Display acyl version, commit SHA and build date`, Run: func(cmd *cobra.Command, args []string) { commit := "https...
package kvraft const ( OK = "OK" ErrNoKey = "ErrNoKey" ErrWrongLeader = "ErrWrongLeader" ) const ( PUT = "Put" APPEND = "Append" GET = "Get" ) type Err string // Put or Append type PutAppendArgs struct { ClientId int64 ClientOperationNumber int Key str...
package microserviceutils import ( "net/http" "io/ioutil" "log" "encoding/json" "io" "net/http/httputil" "fmt" ) func getBody(r interface{}) []byte { switch v := r.(type) { case *http.Request: return readBodyContent(v.Body) case *http.Response: return readBodyContent(v.Body) default: break } return...
package gate import ( "comm/network" ) type agent struct { id int64 conn network.TCPConn gate *Gate backend *Backend } func (a *agent) run() { for { data, err := a.conn.ReadMsg() if err != nil { log.Debug("read message: %v", err) break } } } func (a *agent) OnClose() { } func (a *...
package friend import ( "github.com/gin-gonic/gin" commands "spapp/src/commands/friend" helper "spapp/src/common/helpers" "spapp/src/models/apimodels" friendmodels "spapp/src/models/apimodels/friend" ) // Block an User docs // @Summary Block an User // @Description As a user, I need an API to block updates from ...
package skiplistutil import ( "fmt" "testing" ) import "github.com/huandu/skiplist" func Test_(t *testing.T) { // Create a skip list with int key. list := skiplist.New(skiplist.Int) // Add some values. Value can be anything. list.Set(12, "hello world") list.Set(34, 56) list.Set(78, 90.12) // Get element b...
package main import ( "fmt" "github.com/huichen/sego" ) func main() { var segmenter sego.Segmenter segmenter.LoadDictionary("3.分词/dictionary.txt") // 分词 text := []byte("支持普通和搜索引擎两种分词,支持用户词典、词性标注,可运行JSON RPC服务。") segments := segmenter.InternalSegment(text, true) // 处理分词结果 // 支持普通模式和搜索模式两种分词,见代码中SegmentsToS...
package database import ( "dappapi/global/orm" "dappapi/tools/config" "bytes" "strconv" _ "github.com/go-sql-driver/mysql" //加载mysql "github.com/jinzhu/gorm" log "github.com/sirupsen/logrus" ) var ( DbType string Host string Port int Name string Username string Password string ) func (e *...
package proxy_test import ( "strings" "testing" "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/proxy" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" ) var ( globalProxyConfig = []corev1.EnvVar{ { Name: "HTTP_PROXY", Value: "http://foo.com:8080", }, { Name: ...
package leetcode func reverseKGroup(head *ListNode, k int) *ListNode { if head == nil { return nil } i := head j := head for count := 0; count < k-1; count++ { j = j.Next if j == nil { return i } } next := j.Next j.Next = nil reverse(i) i.Next = reverseKGroup(next, k) return j } func reverse(hea...
// Package bob implement Bob's response package bob import ( "strings" ) // Hey return response of Bob func Hey(remark string) string { remark = strings.TrimSpace(remark) if remark == "" { return "Fine. Be that way!" } if string(remark[len(remark)-1]) == "?" { if strings.ToUpper(remark) == remark && strings....
//+build ignore package main import ( "bufio" "encoding/json" "errors" "fmt" "github.com/anaskhan96/soup" "io/ioutil" "log" "net/http" "os" "path/filepath" "strconv" "strings" "time" ) type ( UniverseRegions []int32 UniverseRegion struct { Constellations []int32 `json:"constellations,omitempty"` ...
package main import ( "context" "encoding/json" "fmt" assetfs "github.com/elazarl/go-bindata-assetfs" "github.com/idoubi/goz" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" "github.com/qiniu/api.v7/v7/auth/qbox" "github.com/qiniu/api.v7/v7/storage" "github.com/spf13/viper" "go.uber.org/z...
package main import ( "bufio" "errors" "github.com/ziutek/mymysql/autorc" "log" "os" "unicode" ) type event struct{} func readLine(r *bufio.Reader) (string, bool) { l, isPrefix, err := r.ReadLine() if err != nil && isPrefix { err = errors.New("line too long") } if err != nil { log.Print("Can't read lin...
// Copyright (c) 2022 Cisco and/or its affiliates. // 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 l...
// Licensed to Elasticsearch B.V. under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. Elasticsearch B.V. licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use ...
package f_test import ( "fmt" . "github.com/TsuyoshiUshio/GoMock/func" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) func mock_getKeyVault(name string) string { fmt.Printf("**Fakeit") fmt.Println() return fmt.Sprintf("Fake: KeyVault Call %s", name) } var _ = Describe("Secret Value Client", func() {...
package utils import ( "bytes" "crypto/md5" "fmt" "github.com/hxangel/dogo" "io" "log" "math/rand" "net/smtp" "os" "reflect" "strconv" "strings" "time" ) var ( loger = log.New(os.Stdout, "[libs] ", log.Ldate|log.Ltime) env = "product" ) func GetConfig(filename string, name string) string { cfgpath ...
package packet import ( "fmt" "strconv" "strings" ) type Token struct { Uid int64 `json:"uid"` Key string `json:"key"` Sign string `json:"sign"` Rand int64 `json:"rand"` Exp int64 `json:"exp"` } func (t *Token) String() string { return fmt.Sprintf("%d|%s|%s|%d|%d", t.Uid, t.Key, t.Sign, t.Exp, t.Rand)...
package main import ( "fmt" "io" "log" "net/http" "os" "strconv" "strings" "time" "github.com/aclindsa/ofxgo" ) func newRequest(bank *bank, acc *account) (ofxgo.Client, *ofxgo.Request) { basicClient := ofxgo.BasicClient{ AppID: "QWIN", AppVer: "2400", SpecVersion: ofxgo.OfxVersion211, } ...
package app import ( "strconv" "strings" "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/layout" "fyne.io/fyne/v2/widget" ) type About struct { Author string MajorVersion int MinorVersion int PatchVersion int License string } func NewAbout() About { return About{ Author: ...
package rsa import ( "CryptCode/utils" "crypto" "crypto/rand" "crypto/rsa" "crypto/x509" "encoding/pem" "flag" "fmt" "io/ioutil" "os" ) const RSA_PRIVATE = "RSA PRIVATE KEY" const RSA_PUBLIC = "RSA PUBLIC KEY" /** * 私钥: * 公钥: * 汉森堡 */ func CreatePairKeys() (*rsa.PrivateKey,error) { //1、先生成私钥 //var bi...
/* Copyright 2020 The SuperEdge 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 interactor import ( "os" "github.com/sem-onyalo/wimbyai-api/service/request" "github.com/sem-onyalo/wimbyai-api/service/response" ) // Config is an interactor for retrieving config values type Config struct { } // NewConfig returns a reference to the config interactor func NewConfig() *Config { return &...
package main import ( "fmt" "sort" ) func main() { fmt.Println("Min Stack") minStack := Constructor() minStack.Push(3) minStack.Push(10) minStack.Push(5) } type MinStack struct { stack []int minData []PairData } type PairData struct { value int pos int } func NewPairData(v, p int) PairData { retur...
package rest import ( "fmt" "net/http" "strconv" "github.com/gorilla/mux" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/types/rest" "github.com/irisnet/irismod/modules/random/types" ) func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { // query random by the request id r...
package Artisan import ( "strconv" jsoniter "github.com/json-iterator/go" ) // interface数组转int数组 func InterfacesToInts(from []interface{}) (to []int) { for _, v := range from { to = append(to, v.(int)) } return to } // interface数组转string数组 func InterfacesToStrings(from []interface{}) (to []string) { for _, ...
// ClueGetter - Does things with mail // // Copyright 2016 Dolf Schimmel, Freeaqingme. // // This Source Code Form is subject to the terms of the two-clause BSD license. // For its contents, please refer to the LICENSE file. // package core import ( cg_lua "cluegetter/lua" "github.com/yuin/gopher-lua" "io/ioutil" ...
// Package repository provides real implementation of storing data. // It doesn't necessarily a database. It can be a file or in-memory. package repository
package admin import ( "github.com/apache/thrift/lib/go/thrift" "github.com/go-xe2/xthrift/pdl" ) type RegSvcGetProvincesListArgs struct { *pdl.TDynamicStructBase fieldNameMaps map[string]string fields map[string]*pdl.TStructFieldInfo } var _ pdl.DynamicStruct = (*RegSvcGetProvincesListArgs)(nil) var _ ...
package logging import ( "fmt" "net" "github.com/sirupsen/logrus" ) type SocketHook struct { socketPath string } func (SocketHook) Levels() []logrus.Level { return []logrus.Level{ logrus.PanicLevel, logrus.FatalLevel, logrus.ErrorLevel, logrus.WarnLevel, logrus.InfoLevel, logrus.DebugLevel, } } v...
package datacenters import ( "github.com/s-matyukevich/centurylink_sdk/base" "github.com/s-matyukevich/centurylink_sdk/models" ) type GetDatacenterGroupRes struct { Connection base.Connection Id string Name string Links []models.Link } var _ models.LinkModel = (*GetDatacenterGroupRes)(nil) ...
package model import ( st "bareksa-test/struck" "context" ) type News struct { ID string Name string TopicID string Status string CreateBy string UpdateBy string CreateDate string UpdateDate string } type NewsFilter struct { Status []string Topics []string } type ListResponse st...
// Copyright 2015-2018 trivago N.V. // // 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 ...
package tmp const ServerTmp = `package core import ( "fmt" "net/http" "os" "os/signal" {{if gt (len .DBS) 0}} {{printf "\"%v/core/database\"" .ModuleName}}{{end}} {{printf "\"%v/helper\"" .ModuleName}} {{printf "\"%v/hub\"" .ModuleName}} ) type Server interface { Start() error Close() } type server struct ...
package web import ( "fmt" "html/template" "io" "net/http" "github.com/Sirupsen/logrus" "github.com/juju/errors" r "gopkg.in/dancannon/gorethink.v2" ) type Handler func(db *r.Session, w http.ResponseWriter, r *http.Request) error func middleware(db *r.Session, handler Handler) http.HandlerFunc { return func...
package main import "io" import "fmt" import "sync" import "time" import "bytes" import "strconv" import "sync/atomic" import "math/rand" import "github.com/bnclabs/gostore/llrb" import humanize "github.com/dustin/go-humanize" func perfllrb() error { setts := llrb.Defaultsettings() index := llrb.NewLLRB("dbperf", ...
package main import ( "fmt" "goci/native" ) func main() { fmt.Println("Beginning tests") oci, err := native.NewEnvironment() if err != nil { panic(err) } srv, err := oci.BasicLogin("apps","apps", "192.168.56.101:1521/ORCL") if err != nil { panic(err) } fmt.Println("srv: ", srv) stmt, err := srv.Ne...
// Copyright 2015 The Chromium 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 main import ( "runtime" "github.com/luci/luci-go/client/internal/common" "github.com/luci/luci-go/client/isolatedclient" "github.com/maruel/...
/* Copyright 2020 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, ...
package Core var guid int64 = 0 type BossMgr struct { } func CreateObjID() GUID { guid++ id := GUID{AppID: 1, Value: guid} return id }
/* Description Assume you have a square of size n that is divided into n × n positions just as a checkerboard. Two positions (x1, y1) and (x2, y2), where 1 ≤ x1, y1, x2, y2 ≤ n, are called “independent” if they occupy different rows and different columns, that is, x1 ≠ x2 and y1 ≠ y2. More generally, n positions are ...
package main import "fmt" func main() { for i := 0; i <= 100; i++ { fmt.Println(i) } for k := 0; k < 5; k++ { fmt.Println(k) } for i := 0; i < 10; i++ { for j := 0; j < 3; j++ { fmt.Println(i) fmt.Printf("The outer loop: %d The inner loop:%d\n", i, j) } } //do while loop ( 3 ways) c := 3 for...
package thethingsnetwork import ( "os" "os/user" log "github.com/Sirupsen/logrus" ) // getID retrns the ID of this ttnctl func getID() string { id := "" if user, err := user.Current(); err == nil { id += "-" + user.Username } if hostname, err := os.Hostname(); err == nil { id += "@" + hostname } return ...
package main import "fmt" import "sort" func main() { fmt.Println("---Create maps") names := createMaps() fmt.Println("\n---Delete elements") deleteElements(names) //fmt.Println("\n---Add elements") addElements(names) fmt.Println("\n---Print elements") printValues(names) fmt.Println("\n---Sort a map") sortM...
/* Go Language Raspberry Pi Interface (c) Copyright David Thorpe 2016-2018 All Rights Reserved Documentation http://djthorpe.github.io/gopi/ For Licensing and Usage information, please see LICENSE.md */ package main import ( "fmt" "os" "regexp" "strings" "time" // Frameworks "github.com/djthorp...
package pods import "github.com/square/p2/pkg/types" type ReadOnlyPolicy struct { defaultReadOnly bool whitelist []types.PodID blacklist []types.PodID } func NewReadOnlyPolicy(defaultReadOnly bool, whitelist []types.PodID, blacklist []types.PodID) ReadOnlyPolicy { return ReadOnlyPolicy{ defaultRead...
/* Copyright IBM Corporation 2020 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 di...
package validator import ( //"reflect" "fmt" "regexp" "testing" ) func TestGetArguments(t *testing.T) { val1, val2, err := getArguments("len(1:2)", "len") if err != nil { t.Fatalf("error good values failed to parse: %v", err) } if val1 != "1" && val2 != "2" { t.Fatalf("error values are not correct %s %s",...
package main import "fmt" func main() { const ( firstName string = "Muhammad" lastName = "Zhuhry" value = 1000 ) //it's okay if you not use constant variable, go will not giving error //fmt.Println(firstName) fmt.Println(lastName) fmt.Println(value) }
package controllers import ( "encoding/json" "fmt" "io/ioutil" "math" "net/http" "strconv" "strings" "sync" "time" "cartracker.api/common" "cartracker.api/data" "cartracker.api/services" "github.com/gorilla/mux" mgo "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) // Index - home page func Index(w http.Resp...
package proto import ( "errors" "fmt" "net" "strings" "github.com/Huawei/eSDK_K8S_Plugin/src/utils" "github.com/Huawei/eSDK_K8S_Plugin/src/utils/log" ) func GetISCSIInitiator() (string, error) { output, err := utils.ExecShellCmd("awk 'BEGIN{FS=\"=\";ORS=\"\"}/^InitiatorName=/{print $2}' /etc/iscsi/initiatorna...
package main import ( "fmt" "log" "github.com/hodgesds/perf-utils" "golang.org/x/sys/unix" ) func main() { profileValue, err := perf.CPUInstructions(func() error { testLL(1000) return nil }) if err != nil { log.Fatal(err) } fmt.Printf("CPU instructions: %+v\n", profileValue) println("") entries := ...
package main import "time" type Todo struct { Id int "json:id" Name string "json:name" Completed bool "json:completed" Due time.Time "json:due" } type Todos []Todo
package main import ( _ "quickstart/routers" "github.com/astaxie/beego" _ "github.com/astaxie/beego/session/redis" "quickstart/controllers" "github.com/astaxie/beego/logs" "time" "errors" "github.com/astaxie/beego/toolbox" ) type DatabaseCheck struct { } func (dc *DatabaseCheck) Check() error { if 1==2 { ...
package account import ( "context" "testing" "go.mongodb.org/mongo-driver/bson/primitive" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "go.mongodb.org/mongo-driver/bson" repoimpl "williamfeng323/mooncake-duty/src/infrastructure/db/repo_impl" ) func TestAccountService(t *testing.T) { RegisterFailHa...
package main import ( "context" "flag" "github.com/cloudevents/sdk-go/v2/binding" "go.uber.org/zap" "knative.dev/eventing-kafka/pkg/channel/channel" "knative.dev/eventing-kafka/pkg/channel/constants" "knative.dev/eventing-kafka/pkg/channel/env" channelhealth "knative.dev/eventing-kafka/pkg/channel/health" "kn...
package isaac const ( playablesBasePath = "/api/v1/playables" ) type PlayablesService interface { Add(NewPlayable) (Playable, error) Get(ID) (Playable, error) List() ([]Playable, error) Remove(Playable) error Update(Playable) (Playable, error) } type PlayablesServiceOp struct { client *Client } type NewPlaya...
package main import ( "fmt" "math" ) // struct to hold the input data type Street struct { From string To string Distance int } // struct to hold information regarding the shortest path type PathData struct { ShortestDistance int PreviousLocation string } // struct to store location data in an easy to access...
package accounts import ( "encoding/json" "fmt" "huobi-sdk/pkg/utils" "io/ioutil" "net/http" ) // GetAccountInfo 获取账户基本信息 func GetAccountInfo() (*GetAccountInfoResponse, error) { request, err := http.NewRequest("GET", "/v1/account/accounts", nil) if err != nil { return nil, err } utils.ReqBuilder.Sign(requ...
package main import ( "../src/router" "fmt" ) func main() { echo := router.New() if err := echo.Start(":8000"); err != nil { fmt.Println("Error") } }
package unpacker import ( "errors" "io" "os" "path/filepath" "time" "github.com/Cloud-Foundations/Dominator/lib/format" proto "github.com/Cloud-Foundations/Dominator/proto/imageunpacker" ) func (u *Unpacker) getRaw(streamName string) (io.ReadCloser, uint64, error) { u.updateUsageTime() defer u.updateUsageTi...
package muxadapter import ( "fmt" "log" "net/http" "os" domain "github.com/AlejandroWaiz/novels-box/internal/domain" "github.com/gorilla/mux" ) type MuxAdapter struct { domainport domain.Port } func CreateMuxAdapter(domain domain.Port) *MuxAdapter { return &MuxAdapter{domainport: domain} } func (ma *MuxAda...
package signal import "log" // Logger represents the logging APIs required by this package. type Logger interface { Info(...interface{}) Debug(...interface{}) } type stdLogger struct{} func (stdLogger) Debug(...interface{}) {} func (stdLogger) Info(args ...interface{}) { log.Println(args...) }
package controllers import ( "github.com/barrydev/api-3h-shop/src/actions" "github.com/barrydev/api-3h-shop/src/model" "github.com/gin-gonic/gin" "strconv" ) func GetListCustomer(c *gin.Context) (interface{}, error) { var query model.QueryCustomer err := c.ShouldBindQuery(&query) if err != nil { return nil...
package common import ( "sync" ) type Worker struct { concurrent chan int finish chan int num int lock *sync.Mutex } func NewWorker(size int) *Worker { return &Worker{ concurrent: make(chan int, size), finish: make(chan int, 10), lock: &sync.Mutex{}, } } func (w *Worker) Run() { w.conc...
package server import ( "context" "fmt" "net/http" "os" "os/signal" "syscall" "github.com/moorara/flax/cmd/config" "github.com/moorara/log" ) // HTTPServer is the interface for http.Server type HTTPServer interface { ListenAndServe() error Shutdown(context.Context) error } // APIServer is an http server f...
package routines import ( "PWGo/src/conf" "fmt" "math/rand" "strconv" "time" ) func Machine(config MachineConfig, tasks chan chan Task, backdoor chan interface{}) { var working = true for { select { case channel := <-tasks: for task := range channel { if working { task.Broken = false task....
package storage import ( "code.google.com/p/go-uuid/uuid" "database/sql" "github.com/kiljacken/tagger" _ "github.com/mattn/go-sqlite3" "log" ) type SqliteStorage struct { db *sql.DB } // NewSqliteStorage returns a new storage engine backed by an in memory sqlite database // TODO: Support file databases, maybe ...
package romulus import ( "path/filepath" "strings" "sync" "time" "golang.org/x/net/context" "github.com/coreos/etcd/client" ) var ( etcdDebug = false ) type EtcdClient interface { Add(key, val string) error Keys(pre string) ([]string, error) Del(key string) error SetPrefix(pre string) } type realEtcdCl...
package v1 import ( corev1 "github.com/appvia/hub-apis/pkg/apis/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // NamespaceClaimSpec defines the desired state of NamespaceClaim // +k8s:openapi-gen=true type NamespaceClaimSpec struct { // Use is the owner of the namespace i.e. the cluster // +k8s:openap...
// Licensed to SolID under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. SolID licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use this file except in compli...
// Package validation is a collection of functions to perform useful true/false validations. package validation import ( "regexp" "strings" ) // Email validates that the provided string is a valid email address. func Email(email string) bool { // Obtained from: https://html.spec.whatwg.org/multipage/input.html#val...
package main import ( "directorio-tap/controllers" "directorio-tap/database" "log" "os" "github.com/go-playground/validator" "github.com/joho/godotenv" "github.com/labstack/echo" "github.com/labstack/echo/middleware" ) // CustomValidator is a custom validator type CustomValidator struct { validator *validat...
package yolosvc import ( "context" "time" "berty.tech/yolo/v2/go/pkg/yolopb" ) func (svc *service) Status(ctx context.Context, req *yolopb.Status_Request) (*yolopb.Status_Response, error) { ret := yolopb.Status_Response{ Uptime: int32(time.Since(svc.startTime).Seconds()), } // db // FIXME: check if db is a...
package soap import ( "bytes" "crypto/tls" "encoding/xml" "fmt" "io" "io/ioutil" "log" "mime/multipart" "net" "net/http" "strings" "time" "github.com/pkg/errors" ) type RequestEnvelope struct { XMLName xml.Name `xml:"soap:Envelope"` XmlnsSoap string `xml:"xmlns:soap,attr"` Header *...
package main import ( "fmt" "os" "runtime" rspecs "github.com/opencontainers/runtime-spec/specs-go" "github.com/opencontainers/runtime-tools/specerror" "github.com/opencontainers/runtime-tools/validation/util" ) func main() { if "linux" != runtime.GOOS && "solaris" != runtime.GOOS { util.Skip("POSIX-specifi...
// Source : https://oj.leetcode.com/problems/symmetric-tree/ // Author : Austin Vern Songer // Date : 2016-03-15 /********************************************************************************** * * Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). * * For examp...
package gen import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/vugu/html" ) func TestEmitForExpr(t *testing.T) { tests := []struct { name string node *html.Node expectedError string expectedResult string }{ { name: ...
package railfence import ( "sort" ) func Encode(input string, rails int) string { output := []byte{} for index := 0; index < len(input); index++ { output = append(output, ' ') } currentIndex := 0 for railIndex := 0; railIndex < rails; railIndex++ { for _, mod := range moduliFor(railIndex, rails, len(input))...
package refImpl import ( "context" "crypto/tls" "encoding/json" "fmt" "github.com/go-ocf/kit/security/certManager" "google.golang.org/grpc" "github.com/go-ocf/cloud/grpc-gateway/service" "github.com/go-ocf/kit/log" kitNetGrpc "github.com/go-ocf/kit/net/grpc" "github.com/go-ocf/kit/security/jwt" "google.g...
/* You are given an integer n as input, and, regardless of the current date, must return the calendar year (Gregorian calendar, other calendars not allowed) taking place n seconds from now. Rules You may not assume that the current year is 2021. In other words, imagine a user testing your solution in five years. ...
// Licensed to SolID under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. SolID licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use this file except in compli...