text
stringlengths
11
4.05M
package main import ( "flag" "fmt" "log" "os" "path/filepath" "strings" "github.com/KyleBanks/depth" ) func main() { rp := flag.String("r", "", "path of the downloaded github repos") of := flag.String("o", "deps.csv", "output file") flag.Parse() out, err := os.Create(*of) if err != nil ...
package str import ( "bytes" "strings" "unicode" "unicode/utf8" ) func TrimStringSlice(raw []string) []string { if raw == nil { return []string{} } cnt := len(raw) arr := make([]string, 0, cnt) for i := 0; i < cnt; i++ { item := strings.TrimSpace(raw[i]) if item == "" { continue } arr = append...
package checker import ( "strings" "github.com/ryanchew3/flexera-coding-challenge/internal/model" ) // getKeys gets the keys of in incoming mapstructure func getKeys(in map[int64][]*model.Computer) []int64 { keys := make([]int64, len(in)) i := 0 for k := range in { keys[i] = k i++ } return keys } // Proc...
// 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 main func sum(a []int) int { if len(a) == 1 { return a[0] } return a[0] + sum(a[1:]) } func main() { a:=[]int{1,8,3,2} println(sum(a)) }
package verify import ( "errors" "strings" verify_method "github.com/winily/go-utils/verify/method" ) type Tag struct { Scenes []string Methods []verify_method.Method Message string } func TagParse(tag string) Tag { tags := strings.Split(tag, ";") result := Tag{} for _, tag := range tags { tagitmes := s...
/* * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. * Licensed under the MIT License (the "License"); you may not use this file except * in compliance with the License. You may obta...
package endpoints import ( "context" "encoding/json" "fmt" "net/http" "time" "github.com/google/uuid" "github.com/sumelms/microservice-course/pkg/validator" "github.com/go-kit/kit/endpoint" kithttp "github.com/go-kit/kit/transport/http" "github.com/sumelms/microservice-course/internal/course/domain" ) t...
// 21. Implement the MT19937 Mersenne Twister RNG package main import ( "bufio" "flag" "fmt" "os" ) const ( arraySize = 624 offset = 397 multiplier = 1812433253 upperMask = 0x80000000 lowerMask = 0x7fffffff coefficient = 0x9908b0df temperMask1 = 0x9d2c5680 temperMask2 = 0xefc60000 ) func mai...
// Package wasmhttp (github.com/nlepage/go-wasm-http-server) allows to create a WebAssembly Go HTTP Server embedded in a ServiceWorker. // // It is a subset of the full solution, a full usage is available on the github repository: https://github.com/nlepage/go-wasm-http-server package wasmhttp
package main import ( "context" "flag" "fmt" "github.com/markbates/pkger" "io" "log" "net/http" "os/user" "time" "github.com/fsnotify/fsnotify" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" "github.com/go-chi/cors" remote "github.com/mkozhukh/go-remote" ) var configPath string var hub *rem...
package dashboard import ( "fmt" "net/http" "strings" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance" "github.com/iotaledger/wasp/packages/coretypes" "github.com/iotaledger/wasp/packages/kv/codec" "github.com/iotaledger/wasp/packages/vm/core/accounts" "github.com/iotaledger/wasp/plugin...
package handlebars import ( "github.com/stretchr/testify/assert" "testing" ) func TestTextNode(t *testing.T) { n := NewTextNode("blah") assert.Equal(t, `"blah"`, n.String()) } func TestTextNodeExecute(t *testing.T) { ctx := map[string]interface{}{"a": "AAA"} assert.Equal(t, `a`, NewTextNode("a").Execute(ctx)) ...
package db import ( "github.com/boltdb/bolt" "strconv" ) const mapping = "mapping" const tracks = "tracks" type Persistent struct { *bolt.DB } func NewPersistent(db *bolt.DB) *Persistent { db.Update(func(tx *bolt.Tx) error { _, err := tx.CreateBucket([]byte(mapping)) if err != nil { return err } _, e...
package bean import ( "encoding/base64" "log" "time" "github.com/astaxie/beego/orm" "github.com/golang/protobuf/proto" pkgProto "crazyant.com/deadfat/pbd/go" ) // --------------------------------------------------------------------------- const ( NOTIFY_PAYMENT = uint32(1) ) type Notify struct { ID ...
package stat import ( "net/http" "time" goKitLog "github.com/go-kit/kit/log" lib "github.com/syedomair/plan-api/lib" ) type StatEnv struct { Logger goKitLog.Logger StatRepo StatRepositoryInterface Common lib.CommonService } func (env *StatEnv) GetTotalUserCountLast30Days(w http.ResponseWriter, r *http.Re...
package utils func IfThenElse(cond bool, a interface{}, b interface{}) interface{} { if cond { return a } else { return b } }
package main import "fmt" func main() { var numOfRunes, minFriendship int fmt.Scanf("%d %d", &numOfRunes, &minFriendship) runes := make(map[string]int) for i := 0; i < numOfRunes; i++ { var s string var n int fmt.Scanf("%s %d", &s, &n) runes[s] = n } var numOfRunesUsed int fmt.Scanf("%d", &numOfRune...
/* Copyright © 2022 SUSE LLC 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 dist...
/* @Time : 2019/5/11 14:40 @Author : yanKoo @File : mian.go @Software: GoLand @Description: */ package main import ( "cache" "encoding/json" "log" "time" ) type interphoneMsg struct { Uid string `json:"uid"` MsgType string `json:"m_type"` Md5 string `json:"md5"` GId string `json:"grp_id"`...
package game // 用户相关 const ( NoPermission int32 = iota + 100 ReqLogin // 登录请求 ResLogin // 响应登录结果 ReqReg // 用户注册 ResReg // 响应注册结果 ReqReset // 重置密码 ResReset // 响应重置密码结果 ReqBind // 账号绑定 ResBind // 响应绑定结果 ReqUserInfo // 获取用户信息 ResUser...
package monitoring import ( "Agamoto/linenotify" "log" "net/http" "strconv" "time" ) // // type CCUType struct { // AllUser string // IOSCCU string // AndriodCCU string // } var allCCU = 500 var sendTimeStamp = time.Now() var countRecvUpdate int64 = 0 var lastCount int64 = 1 var lastC...
package main import ( "github.com/profzone/eden-framework/pkg/application" "github.com/profzone/eden-framework/pkg/context" "github.com/sirupsen/logrus" "longhorn/upload-packager/internal/global" "longhorn/upload-packager/internal/routers" ) func main() { app := application.NewApplication(runner, &global.Config...
package mqtt import ( "context" "encoding/json" "time" mqtt "github.com/eclipse/paho.mqtt.golang" "github.com/pkg/errors" uuid "github.com/satori/go.uuid" "github.com/batchcorp/plumber-schemas/build/go/protos/opts" "github.com/batchcorp/plumber-schemas/build/go/protos/records" "github.com/batchcorp/plumber...
package models import ( "database/sql" "encoding/json" "web/ant/kernel" "web/ant/kernel/databases" ) /** * 模型查询结构 * * param results []map[string]interface 数据结果集 */ type ModelQuery struct { results []map[string]interface{} } /** * 返回模型构建对象 * * param string tableName 数据表名 * param string dbName 数据库名 */ fu...
package keeper import ( "fmt" "github.com/irisnet/irishub/app/v2/coinswap/internal/types" sdk "github.com/irisnet/irishub/types" "github.com/stretchr/testify/require" "testing" "time" ) var ( native = sdk.IrisAtto ) func TestGetUniId(t *testing.T) { cases := []struct { name string denom1 s...
package util import ( eventv1 "github.com/redhat-cop/events-notifier/pkg/apis/event/v1" notifyv1 "github.com/redhat-cop/events-notifier/pkg/apis/notify/v1" ) type SharedResources struct { Subscriptions *[]eventv1.EventSubscription Notifiers *[]notifyv1.Notifier } func NewSharedResources() SharedResources { ...
// Starting with the code below, pull values off the channel using a select statement // package main // // import ( // "fmt" // ) // // func main() { // q := make(chan int) // c := gen(q) // // receive(c, q) // // fmt.Println("about to exit") // } // // func gen(q <-chan int) <-chan int { // c := make(chan int) ...
package sample_data import ( "math/rand" "time" "github.com/google/uuid" ) // by default random will use fix seed to create then some of random value will be remain the same // we can fix it by tell random to use diffenrent seed to run // by using below code func init() { rand.Seed(time.Now().UnixNano()) } func...
/* Description The Lab Cup Table Tennis Competition is going to take place soon among laboratories in PKU. Students from the AI Lab are all extreme enthusiasts in table tennis and hold strong will to represent the lab in the competition. Limited by the quota, however, only one of them can be selected to play in the c...
package cors import ( "github.com/gin-gonic/gin" "net/http" ) var Cors = func(c *gin.Context) { method := c.Request.Method c.Header("Access-Control-Allow-Origin", "*") c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, UPDATE") c.Header("Access-Control-Allow-Headers", "*") if method == ...
package models import ( "fmt" "github.com/jinzhu/gorm" "golang-http-server/config" ) type Employee struct { gorm.Model Name string `json:"name"` Surname string `json:"surname"` Age int `json:"age"` } func (e *Employee) ValidationModel() map[string]string { validations := make(map[string]string) i...
package main import ( "encoding/json" "fmt" ) type Return struct { Version string `json:"version"` SessionAttributes SessionAttributes `json:"SessionAttributes"` Response Response `json:"response"` ShouldEndSession bool `json:"shouldEndSession"` } func NewRe...
package pie_test import ( "github.com/elliotchance/pie/v2" "github.com/stretchr/testify/assert" "testing" ) var containsTests = []struct { ss []float64 contains float64 expected bool }{ {nil, 1, false}, {[]float64{1, 2, 3}, 1, true}, {[]float64{1, 2, 3}, 2, true}, {[]float64{1, 2, 3}, 3, true}, {[]fl...
package main import "fmt" //make()函数创造切片 /* 1. 要判断一个切片是否是空, 要用 len(s) === 0 来判断, 不应该使用 s == nil 来判断 */ func main() { s1 := make([]int, 5, 10) fmt.Printf("s1-%v len(s1)-%d cap(s1)-%d", s1, len(s1), cap(s1)) }
// Copyright 2021 Clivern. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. package driver import ( "github.com/stretchr/testify/mock" "go.etcd.io/etcd/clientv3" ) // EtcdMock type type EtcdMock struct { mock.Mock } // Connect mock func (e *...
package main import ( "os" "testing" ) var h handler func TestMain(m *testing.M) { h, _ = New() defer h.db.Close() os.Exit(m.Run()) } func Test_handler_lookupIDwithEmail(t *testing.T) { type args struct { email string } tests := []struct { name string args args wantUserID int wantErr ...
package controllers import ( "github.com/astaxie/beego" ) type DefaultController struct { beego.Controller } func (c *DefaultController) Get() { beego.SetLevel(beego.LevelDebug) // beego.Alert("this is alert") c.Data["Email"] = "suhanyujie@qq.com" c.Data["Html1"] = "<div>Hello beego</div>" c.Data["IsIndex"] ...
package main import ( "github.com/gin-gonic/gin" "github.com/mp02/accounting-notebook/api" ) // @title Accounting-notebook // @version 1.0 // @description API Restful for credit and debit transactions // @contact.name Martin Pruyas // @contact.url https://www.linkedin.com/in/martin-pruyas/ // @contact.email o.gema...
package main import ( "fmt" "sync" ) func main() { var wg sync.WaitGroup var lr LimitRate lr.SetRate(3) for i:=0;i<10;i++{ wg.Add(1) go func(){ if lr.Limit() { fmt.Println("Got it!")//显示3次Got it! } wg.Done() }() } wg.Wait() }
package main import ( "fmt" "net/http" pinyin "github.com/mozillazg/go-pinyin" ) func main() { fmt.Println("hello") hans := "中国人" // 默认 a := pinyin.NewArgs() fmt.Println(pinyin.Pinyin(hans, a)) http.ListenAndServe(":8080", http.FileServer(http.Dir("./"))) }
package unio //noinspection GoUnusedConst const DATE = "2006-01-02" //noinspection GoUnusedConst const DATETIME = "2006-01-02 15:04:05"
package config // based on https://cbonte.github.io/haproxy-dconv/1.6/configuration.html func NewDefault() *Default { return &Default{ Values: make([]Line, 0), } } type Default struct { // blindly store all defaults for now Values []Line } // parse the lines in a default func (me *Parser) defaultSection(line...
package tx import ( "sync" ) type GoroutineMethodStackMap struct { m map[int64]*StructField lock sync.RWMutex } func (g GoroutineMethodStackMap) New() GoroutineMethodStackMap { return GoroutineMethodStackMap{ m: make(map[int64]*StructField), } } func (g *GoroutineMethodStackMap) Put(k int64, methodInfo *St...
// Copyright 2017 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 shortest_path import ( "container/heap" "container/list" ) type Graph struct { v int adj []*list.List } type edge struct { sid, tid int // 边的起始/终止顶点编号 w int // 边的权重 } func NewGraph(v int) *Graph { graph := &Graph{ v: v, adj: make([]*list.List, v), } for i := range graph.adj { graph...
package main type SystemSpec struct { OSName string `json:osName` Processor string `json:processor` }
package html2rst import ( "golang.org/x/net/html" ) func td2rst(td *html.Node) string { s := "" for c := td.FirstChild; c != nil; c = c.NextSibling { if isTextNode(c) { s += textNode2rst(c) continue } if isAnchorElement(c) { s += a2rst(c) continue } } return s } func tr2rst(tr *html.Node) st...
package main import "sort" func main() { } func eraseOverlapIntervals(intervals [][]int) int { // 按左端点排序 sort.Slice(intervals, func(i, j int) bool { return intervals[i][1] < intervals[j][1] }) right := intervals[0][1] ans := 1 for i := 1; i < len(intervals); i++ { if intervals[i][0] >= right { ans++ ...
// Package ssh contains utilities that help gather logs, etc. on failures using ssh. package ssh import ( "os" "path/filepath" "strings" "github.com/pkg/errors" "github.com/pkg/sftp" "github.com/sirupsen/logrus" "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" utilerrors "k8s.io/apimachinery/pkg/uti...
package main import ( "strings" ) func main() { tests := [10][2]string{ // truthy test {"1234", "1234"}, {"1234", "4321"}, {"1234", "2314"}, {"anagram", "manraag"}, {"anagram", "Anagram"}, {"anagram", "MARGANA"}, // falsy tests {"anagram", "ana gram"}, {"1112", "4321"}, ...
package main import ( "github.com/douglasmakey/go-fcm" "log" ) func main() { // init client client := fcm.NewClient("ApiKey") // You can use your HTTPClient //client.SetHTTPClient(client) data := map[string]interface{}{ "message": "From Go-FCM", "details": map[string]string{ "name": "Name", "user"...
//Package setting provide goil's settings package setting import ( "os" "path/filepath" "strings" "time" "github.com/Unknwon/goconfig" "github.com/howeyc/fsnotify" ) const ( APP_VER = "0.10" ) var ( AppName string AppHost string AppVer string IsProMode bool TimeZone string ) var ( Cfg *goconfi...
package service import ( "github.com/sem-onyalo/wimbyai-api/service/request" ) // API is a boundary to the web api type API interface { Start(request request.StartAPI) }
package sgf import ( "fmt" "strconv" ) // GetRoot travels up the tree, examining each node's parent until it finds the // root node, which it returns. func (self *Node) GetRoot() *Node { node := self for node.parent != nil { node = node.parent } return node } // GetEnd travels down the tree from the node, un...
package machine import ( "fmt" ) // Rotors is a list of rotors used as a part of a machine. type Rotors struct { rotors []*Rotor count int } // NewRotors returns a new, initialized Rotors pointer, and an error if given // rotor list is invalid. func NewRotors(rotors []*Rotor) (*Rotors, error) { if len(rotors) =...
package StringToInteger import "testing" func Test_myAtoi(t *testing.T) { type args struct { str string } tests := []struct { name string args args want int }{ //TODO: Add test cases. { name: "first", args: args{str: "01234"}, want: 1234, }, { name: "second", args: args{str: " -42"...
// +build examples package examples import ( "fmt" "fronius-exporter/pkg/fronius" "log" "time" ) func main() { client, err := fronius.NewSymoClient(fronius.ClientOptions{ URL: "http://symo.ip.or.hostname/solar_api/v1/GetPowerFlowRealtimeData.fcgi", Timeout: 5 * time.Second, }) if err != nil { log.Fa...
package main import ( "fmt" "io/ioutil" "log" "os" "sort" "strings" ) func check(e error) { if e != nil { log.Fatal(e) } } func parseData() (res [][]string) { file := "data" if len(os.Args) > 1 { file = os.Args[1] } rawData, err := ioutil.ReadFile(file) check(err) rows := strings.Split(strings.Tr...
package commands import ( "github.com/mix-go/console" "github.com/mix-go/mix-console-skeleton/commands" ) func init() { Commands = append(Commands, console.CommandDefinition{ Name: "hello", Usage: "\tEcho demo", Options: []console.OptionDefinition{ ...
package onelogin import "testing" // Test the GetUrl() method for generating request URLS func TestGetUrl(t *testing.T) { shards := map[string]string{ "us": "https://api.us.onelogin.com/", "eu": "https://api.eu.onelogin.com/", } for shard,url := range shards { o := OneLogin{Shard...
package kube import ( "reflect" "testing" sfv1alpha1 "github.com/openshift/splunk-forwarder-operator/api/v1alpha1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func TestGenerateService(t *testing.T) { type args struct { instance *sfv1alpha1.SplunkForwarder } tests := []struct...
package analysis import ( "encoding/json" "fmt" cfg "github.com/redisTesting/internal/config" "io/ioutil" "math" "os" "path" ) type ClientData struct { Level string ClientId int TotalSent int MinLat int MaxLat int MaxLatIdx int AvgLat int P50Lat int P95Lat int P99Lat int Start int `json:"sendStart"`...
package main import ( "fmt" "image" "image/color" "image/color/palette" "image/gif" "os" ) // Hands 价格 type Hands struct { img *image.Paletted } // CreateHands ... func CreateHands() *Hands { return &Hands{img: image.NewPaletted(image.Rect(0, 0, 50, 7), palette.Plan9)} } //Make 价格的右上角坐标 func (p *Hands) Make...
package main /* #include <stdio.h> #include <stdlib.h> typedef int (*intFunc) (); int bridge_int_func(intFunc f) { return f(); } int fortytwo() { return 42; } void myprint(char* s) { printf("%s", s); } */ import "C" import ( "fmt" "unsafe" ) func main() { f := C.intFunc(C.fortytwo) fmt.Println(int(C.br...
package main import ( "fmt" "bitbucket.org/egorsteam/bk-tree/internal" levenshtein "github.com/creasty/go-levenshtein" ) type word string // Distance calculates hamming distance. func (x word) Distance(e internal.ObjectTree) internal.TypeOfDistance { a := string(x) b := string(e.(word)) return internal.Int(l...
// SPDX-License-Identifier: Apache-2.0 // Copyright The Linux Foundation package exceptionmaker import ( "fmt" "net/url" "strings" "time" "github.com/spdx/tools-golang/v0/spdx" ) // MakeDocument creates an SPDX Document2_1 entry to which // Packages will be added. func MakeDocument() *spdx.Document2_1 { dates...
package entity import "time" type ToDo struct { Title string Done bool Limit time.Time }
package Problem0407 import ( "fmt" "testing" "github.com/stretchr/testify/assert" ) // tcs is testcase slice var tcs = []struct { heightMap [][]int ans int }{ { [][]int{ []int{5, 5, 5, 1}, []int{5, 1, 1, 5}, }, 0, }, { [][]int{ []int{5, 5, 5, 1}, []int{5, 1, 1, 5}, []int{5, 1, ...
/** Copyright @ 2014 OPS, Qunar Inc. (qunar.com) Author: tingfang.bao <tingfang.bao@qunar.com> DateTime: 14-8-20 下午2:12 */ package form import ( "regexp" "strconv" "strings" "unicode/utf8" ) /** 定义消息映射 */ const ( MSG_REQUIRED = "this field is required" MSG_MAX_LENGTH = "length must less than {0}" MSG_...
package main import ( "fmt" "strings" ) func SlackBlocks_FeedbackMsg(msg FeedbackMsg, text string) []interface{} { if text == "" { text = "How's it going? I'm here to get an update on the status of your bagel chat 😁" } return []interface{}{ map[string]interface{}{ "type": "section", "text": map[strin...
package main import ( "bufio" "encoding/json" "fmt" "log" "net" "os" "path/filepath" "strconv" "strings" "sync" ) // Send is responsible for sending messages through a // generic stream-oriented network connection func send(id int, conn *net.Conn, request []byte) error { var err error var n int n, err = ...
package processors import ( "github.com/vmware/kube-fluentd-operator/config-reloader/fluentd" ) const ( dirPlugin = "plugin" ) // ExtractPlugins looks at the top-level directives in the admin namespace, deletes all <plugin> // and stores the found plugin definitions under GenerationContext.Plugins map keyed by the...
package main import ( "bytes" "fmt" "io" "log" "net" "runtime" "sync" ) var wg sync.WaitGroup func init() { log.SetFlags(log.Lshortfile) } func main() { engine1() } func engine1() { wg.Add(2) lTcpAddr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:8090") if err != nil { log.Fatalln(err) } rTcpAddr, ...
package models_test import ( "github.com/APTrust/exchange/models" "github.com/APTrust/exchange/util/testutil" "github.com/stretchr/testify/assert" "testing" ) func TestNewRestoreState(t *testing.T) { restoreState := models.NewRestoreState(testutil.MakeNsqMessage("999")) assert.NotNil(t, restoreState.PackageSumm...
package server import ( "encoding/json" "errors" "sync" "github.com/dchanman/tactics/src/game" "github.com/sirupsen/logrus" ) const ( nMaxPlayers = 2 rowsLarge = 10 colsLarge = 7 rowsOfPiecesLarge = 3 rowsSmall = 8 colsSmall = 5 rowsOfPiecesSmall = 2 ) var ( errIn...
package agency import ( "bytes" "encoding/csv" "strconv" ) // maxRank is the highest rank that can be used by the data files. const maxRank = 5 type browser struct { rank int typ string name string token []byte } var browsers []*browser func init() { data, _ := dataBrowserCsv() records, err := csv.New...
package fetcher import ( "io" "text/template" ) const templateText = ` <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org...
package machine import ( "bytes" "testing" "github.com/disposedtrolley/goz/internal/memory" "github.com/disposedtrolley/goz/test" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestDecodeZString(t *testing.T) { tests := []struct { Name string Gamefile test....
package nougat import ( "net/http" ) // Doer executes http requests. It is implemented by *http.Client. You can // wrap *http.Client with layers of Doers to form a stack of client-side // middleware. type Doer interface { Do(req *http.Request) (*http.Response, error) } // Sending type APIError struct { Message...
package srpc import ( "bufio" "bytes" "crypto/rand" "flag" "fmt" "net" "os" "runtime" "sync" ) const ( unixClientCookieLength = 8 unixServerCookieLength = 8 unixBufferSize = 1 << 16 ) var ( srpcUnixSocketPath = flag.String("srpcUnixSocketPath", defaultUnixSocketPath(), "Pathname for server U...
package gogen import ( "go/ast" "unicode" "strings" "regexp" ) // Annotation holds information about one annotation, its name // parameters and their values type Annotation struct { name string //may be obsolete bc annotations are indexed in annotation map by their names values map[string]string } //...
package main import ( "os" "go.uber.org/zap" "github.com/gin-contrib/cors" "github.com/gin-contrib/static" "github.com/gin-gonic/gin" ) var ( pgDb, pgUser, pgPassword, pgHost string uploadFolderPath string logger *zap.SugaredLogger ) func main() { loadEnvironmentV...
// 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 models import ( "project/app/admin/models/bo" "project/utils/app" ) // _ResponseLogin swagger登录授权响应结构体 type _ResponseLogin struct { Code app.ResCode `json:"code"` // 业务响应状态码 Message string `json:"message"` // 提示信息 Data struct { Token string `json:"token"` // 授权令牌 } `json:"data"` // 数据 } ...
/* Copyright 2013 The Camlistore 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 /* 1.日志是查找潜在bug, 了解程序工作状态的方式 1.可用于跟踪 & 调试 & 分析代码 2.Go标准库提供了log包, 可对日志做最基本的配置, 开发人员还可自定义日志记录器 3.传统CLI(命令行界面)程序直接将输出写到名为stdout设备上, 所有操作系统都有这种设备, 该设备默认目的地是标准文本输出 1.默认设置下, 终端会显示写到stdou设备上的文本, 这对于单个目的的输出很方便 2.有事会需要同时输出程序信息和执行细节 1.执行细节称为日志 3.为解决程序输出和日志混为一谈, UNIX架构上增加了名为stderr的设备, 该设备为日志默认目的地 4.若想在程序运行期间同...
package main import "fmt" func main() { complexArray1 := [3][]string { []string{"d", "e", "f"}, []string{"g", "h", "i"}, []string{"j", "k", "l"}, } fmt.Printf("The complex array is %v\n", complexArray1) complexArray2 := modifyArray(complexArray1) fmt.Printf("After updated, the complex array is %v\n", co...
package sshKraken // import "github.com/cvasq/sshKraken" import ( "net" "golang.org/x/net/context" ) type EmptyResolver struct{} func (EmptyResolver) Resolve(ctx context.Context, name string) (context.Context, net.IP, error) { return ctx, nil, nil }
package path import ( "strconv" ) // Regular Expressions ile tanımladığınız URL'lerdeki parametreleri döndürür. // Tip dönüşümleriyle uğraşmak zorunda kalınmadan, uygun metod kullanılarak veri elde edilebilir. // Örnek: // URL Mapping Erişim // /customers/312 `/customers/(?P<customerId>\d+)` pv.GetInt32("c...
package writer import ( "encoding/json" "io" "strings" ) type JsonWriter struct { input interface{} } func (j JsonWriter) Bytes() ([]byte, error) { marshalOutput, err := j.Marshal() if err != nil { return nil, err } return marshalOutput.([]byte), nil } func (j JsonWriter) Marshal() (interface{}, error) ...
package main import "fmt" // passed by value - zeroval gets a copy of ival distinct from one in the calling function func zeroval(ival int) { ival = 0 } // passes pointer, dereferences the pointer - assigning value will change value at ref'd address func zeroptr(iptr *int) { *iptr = 0 } func main() { i := 1 fmt...
package ciolite // Api functions that support: users/email_accounts/folders/messages/body import ( "fmt" "net/url" ) // GetUserEmailAccountsFolderMessageBodyParams query values data struct. // Optional: Delimiter, Type. type GetUserEmailAccountsFolderMessageBodyParams struct { // Optional: Delimiter string `json...
package jarviscore import ( "context" "io" "net" "go.uber.org/zap" jarvisbase "github.com/zhs007/jarviscore/base" pb "github.com/zhs007/jarviscore/proto" "google.golang.org/grpc" ) // jarvisServer2 type jarvisServer2 struct { node *jarvisNode lis net.Listener grpcServ *grpc.Server } // newServer...
package bishi import ( "math" ) func JudgeStr(str string) (count int, values string) { length := len(str) if length == 0 { return 0, "" } runne := []rune(str) maps := make(map[rune]int) var strRune = make([]rune, 0) var strRunes = make([][]rune, 0) var max float64 for i, j := 0, 0; i < length; i++ { ite...
package main import ( "bytes" "fmt" "html/template" "io" "log" "net/http" "github.com/Samze/services-demo-basel-2018/config" "github.com/Samze/services-demo-basel-2018/web-app/queue" "github.com/Samze/services-demo-basel-2018/web-app/store" ) type Storer interface { GetImages() ([]store.Image, error) } ty...
package MP4 import ( "bytes" "github.com/panda-media/muxer-fmp4/format/AVPacket" "github.com/panda-media/muxer-fmp4/format/MP4/commonBoxes" ) const ( MEDIA_AV = iota MEDIA_Audio_Only MEDIA_Video_Only ) type FMP4Muxer struct { audioHeader *AVPacket.MediaPacket videoHeader *AVPacket.MediaPacket sequen...
// Created by: Ryan-Shaw-2 // Created on: May 2021 // // This program calculates the volume of a pyramid package main import "fmt" func main() { // This function calculates the volume of a pyramid var length float64 var width float64 var height float64 // input fmt.Println("This program calculates the volume ...
package analyzer import ( "fmt" "go/ast" "golang.org/x/tools/go/analysis/passes/inspect" "golang.org/x/tools/go/ast/inspector" "reflect" //"strings" "golang.org/x/tools/go/analysis" ) var Analyzer = &analysis.Analyzer{ Name: "terraformschemachecker", Doc: "Checks resource schema field order", Run: run, R...
package metaverse import ( "github.com/unixpickle/anyvec" "github.com/unixpickle/essentials" gym "github.com/unixpickle/gym-socket-api/binding-go" ) // Env is a Universe environment implementing anyrl.Env. type Env struct { GymEnv gym.Env Imager *Imager ActionSpace *ActionSpace } // Reset resets the ...