text
stringlengths
11
4.05M
package meta import ( "encoding/json" "encoding/xml" "errors" "strings" ) func Load(bs []byte) (models []Model, apis []Api, err error) { m := &ApiMeta{} err = xml.Unmarshal([]byte(bs), m) if err != nil { return nil, nil, err } models, apis, err = flat(m) if err != nil { return } err = verify(models, ...
package cmd import ( "github.com/spf13/cobra" "github.com/instructure-bridge/muss/config" ) func newBuildCommand(cfg *config.ProjectConfig) *cobra.Command { var cmd = &cobra.Command{ Use: "build", Short: "Build or rebuild services", Long: `Build or rebuild services. Services are built once and then tagge...
// Copyright 2019 Michael DOUBEZ // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to...
package main import ( "encoding/json" "log" "os" "github.com/nlopes/slack" k8s "k8s.io/kubernetes/pkg/client/unversioned" "k8s.io/kubernetes/pkg/watch" ) type message struct { msg string obj string name string reason string component string color string count int eventType ...
package templates //Story struct contains list of arcs type Story struct { Arcs map[string]Arc `json:"arcs"` } //An Arc type may store a chapter or a character type Arc struct { Title string `json:"title"` Story []string `json:"story"` Options []Option `json:"options"` } //Option struct details options and...
package lccc_model type SystemSettingItemDefine struct { Key string `json:"key"` Name string `json:"name"` UiType string `json:"ui_type"` UiParams string `json:"ui_params"` DefaultValue string `json:"default_value"` Introduce string `json:"introduce"` NeedRestart bool `json:"nee...
package data import ( "bytes" "encoding/json" "net/http" "sort" "strconv" "blogpost/entity" ) type BlogPostRepository interface { GetRecentTitles(count int) ([]*BlogSummary, error) GetRecentPosts(count int) ([]*entity.BlogPost, error) CreatePost(post *entity.BlogPost) (*entity.BlogPost, error) UpdatePost(p...
package store import ( "context" "os" "testing" "time" "github.com/dragonflyoss/image-service/contrib/nydus-snapshotter/pkg/daemon" "github.com/stretchr/testify/require" ) func Test_daemon(t *testing.T) { rootDir := "testdata/snapshot" err := os.MkdirAll(rootDir, 0755) require.Nil(t, err) defer func() { ...
package main func findMin(nums []int) int { l, r := 0, len(nums)-1 for l <= r { // l == r 表示范围内只有一个元素了,那么这个元素就是最小值。 if l == r { return nums[l] } mid := (l + r) / 2 // nums[r] == nums[mid] 时,我们无法判断最小值位于左边还是右边,但能确定,最小值一定不在边界 if nums[r] == nums[mid] { r-- } else { if nums[r] > nums[mid] { r =...
package cycle import ( "time" "github.com/imsilence/gocmdb/agent/ens" "github.com/imsilence/gocmdb/agent/entity" "github.com/imsilence/gocmdb/agent/gconf" ) type HeartbeatPlugin struct { config *gconf.Config ens *ens.ENS nextTime time.Time interval time.Duration } func (p *HeartbeatPlugin) Name() str...
package store import ( "bufio" "fmt" "log" "os" "strconv" "strings" "time" "github.com/Nimsaja/DepotPerformance/depot" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" "gonum.org/v1/plot/plotutil" "gonum.org/v1/plot/vg" ) const path = "stocksData.txt" //File store channel inputs to file func File(v float...
package xjwt import ( "encoding/json" "time" "fmt" jose "github.com/go-jose/go-jose/v3" ) // VerifyReasons expresses why a JWT was not valid. type VerifyReasons int32 const ( // JWT_UNKNOWN means the JWT could not be verified for unknown reasons. JWT_UNKNOWN VerifyReasons = 0 // JWT_NOT_PRESENT means the JW...
package authproxy import ( "context" "net/http" "net/http/httptest" "testing" "github.com/stretchr/testify/assert" ) func TestMiddleware_getAccessTokenFromCookie(t *testing.T) { var ( m = &Middleware{} r = httptest.NewRequest(http.MethodGet, "/", nil) accessToken = "foo" ) s, err :...
package awscredentials //https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html //https://github.com/aws/aws-sdk-go //https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/sessions.html import ( "fmt" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github....
package main import ( "context" "testing" "golang.org/x/crypto/bcrypt" "github.com/biswassampads/blog_applications/global" "github.com/biswassampads/blog_applications/proto" "go.mongodb.org/mongo-driver/bson/primitive" ) func Test_authServer_Login(t *testing.T) { global.ConnectToTestDB() pw, _ := bcrypt.Gen...
package main import ( "errors" "fmt" ) func div(x, y int) (int, error) { if y == 0 { return 0, errors.New("division by zero") } return x / y, nil } func log(x int, err error) { fmt.Println(x, err) } func test() (int, error) { return div(5, 0) } func main() { log(test()) }
package FolderDelivery import ( mailProto "MainApplication/proto/MailService" userProto "MainApplication/proto/UserServise" ) func ProtoFolderListResponse(folders []*userProto.FolderNameType) []byte { ans := FolderList{ Code: 200, Folders: ProtoToModelList(folders), } res, err := ans.MarshalJSON() if err...
package plugins import ( "reflect" "testing" ) func TestManager_Handle(t *testing.T) { man := NewManager() man.Handle(TestPlugin{}) if _, ok := man.plugins["TestPlugin"]; !ok { t.Fail() } if _, ok := man.subscriptions["test.answer"]; !ok { t.Fail() } } func TestManager_Handler(t *testing.T) { man := N...
package main import ( "sync" "runtime" "time" "io/ioutil" "os" "fmt" ) type JobFunc func(int, interface{}, chan interface{}) // 主线程 产生bool的channel func threadMain(id int, queue chan interface{}, wg *sync.WaitGroup, job JobFunc) chan bool { quitCommand := make(chan bool, 1) go func() { ...
/* The problem Given a binary number from 0 to 111111 convert it to trinary. (Base 3). Then print the result. Rules No using a list of conversions. Don't cheat You must use a string as the number No compressing the input string As I will be testing the code with several different numbers I can't use compressed str...
package main import ( "encoding/json" "io/ioutil" "log" ) type Config struct { StockCodes []string `json:"stock_codes"` AlarmTime []string `json:"alarm_time"` StaggingTipsOn bool `json:"stagging_tips_on"` } var config Config // LoadConfig from local config json file func LoadConfig() { jsc, err := ioutil.Re...
package main // FIX<E: websockrt 因为 iris 升级之后不兼容,需要修复 func main() { } // // Run first `go run main.go server` // // and `go run main.go client` as many times as you want. // // Originally written by: github.com/antlaw to describe an old issue. // import ( // "encoding/json" // "fmt" // "os" // "os/signal" // "...
// Copyright 2021 Amazon.com, Inc. or its affiliates. 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. A copy of the // License is located at // // http://aws.amazon.com/apache2.0/ // // or in the "license"...
package main import "fmt" func main() { nums := int{-1, 0, 1, 2, -1, -4} finalArr := [][]int{} ansArr := []int{} }
package model import ( "strings" "time" "gorm.io/gorm/clause" "gorm.io/gorm" ) const GlobalConfigTableName = "global_config" const ( // configKey 常量 ConfigSiteConfig = "site_config" //网站配置 ConfigImageBaseUrl = "image_base_url" // 图片域名地址 ConfigPayapiHostAddr ...
package tsmt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document05200101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:tsmt.052.001.01 Document"` Message *RoleAndBaselineRejectionNotificationV01 `xml:"RoleAndBaselnRjctnN...
package gcp import ( "context" "crypto/rand" "fmt" "math/big" "strings" "time" cloudbuild "cloud.google.com/go/cloudbuild/apiv1" "github.com/golang/protobuf/ptypes" "google.golang.org/api/compute/v1" "google.golang.org/api/option" cloudbuildpb "google.golang.org/genproto/googleapis/devtools/cloudbuild/v1" ...
package models type WorkBaseRequest struct { Action string `json:"action" mapstructure:"action"` Hash string `json:"hash" mapstructure:"hash"` }
package grapheme /* BSD License Copyright (c) 2017–21, Norbert Pillmayer All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this ...
package robot import ( "fmt" "github.com/tebeka/selenium" "main/google" "time" ) func Login(username, password, secret string, w_b1 selenium.WebDriver) bool { err := w_b1.Get("http://bibi.cnluyao.cn/bi") if err != nil { fmt.Println("get page faild", err.Error()) return false } wes, err := w_b1.FindElement...
package frontend import ( "github.com/gin-gonic/gin" "net/http" ) func (s *Server) homeGet(ctx * gin.Context) { sessionToken, err := ctx.Cookie("session") if err != nil { ctx.HTML(http.StatusOK, "home.tmpl", gin.H{ "signedIn": false, }) return } status, resp, err := s.callBankService("/...
package main import "fmt" /* Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. */ // Build max heights from both directions (left -> right & right -> left), then for each index find the min height and subtract it fr...
package mongo import ( // Standard Library Imports "context" // External Imports "github.com/globalsign/mgo" ) const ( // IdxCacheRequestID provides a mongo index based on request id. IdxCacheRequestID = "idxRequestId" // IdxCacheRequestSignature provides a mongo index based on token // signature. IdxCache...
package v26 import ( "github.com/giantswarm/versionbundle" ) func VersionBundle() versionbundle.Bundle { return versionbundle.Bundle{ Changelogs: []versionbundle.Changelog{ { Component: "calico", Description: "Update calico to 3.6.1", Kind: versionbundle.KindChanged, }, { Compone...
package unittestutils import ( "context" "fmt" "path/filepath" "testing" "time" "github.com/kubernetes-sigs/multi-tenancy/tenant/pkg/apis" tenancyv1alpha1 "github.com/kubernetes-sigs/multi-tenancy/tenant/pkg/apis/tenancy/v1alpha1" tenant "github.com/kubernetes-sigs/multi-tenancy/tenant/pkg/controller/tenant" ...
package main import ( "fmt" "os" "strings" ) ///////////////////////////////////////////////////////////////////////////////////////////////////// // func CreateTodayDir() (bRet bool) { dir := GetModulePath() + "log/" err := os.MkdirAll(dir, 0777) if err != nil { fmt.Println(err.Error()) } else { bRet = t...
package web import ( "context" "go.uber.org/zap" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" pb "github.com/autograde/aguis/ag" "github.com/autograde/aguis/ci" "github.com/autograde/aguis/database" scms "github.com/autograde/aguis/scm" "github.com/autograde/aguis/web/auth" ) // Autograde...
package util import ( "encoding/json" "math/rand" "time" ) func Now13() int64 { return time.Now().UnixNano() / 1e6 } func Now10() int64 { return time.Now().Unix() } // 当天时间的0点 func DayStart(add time.Duration) int64 { now := time.Now() year, month, day := now.Date() startTime := time.Date(year, month, day, 0...
package main import ( "fmt" "io" "os" ) func printenv(w io.Writer) { e := os.Environ() for _, v := range e { fmt.Fprintf(w, "%v\n", v) } } func main() { printenv(os.Stdout) }
package main import ( "github.com/Lupino/LiquidCrystal" "github.com/hybridgroup/gobot" "github.com/hybridgroup/gobot/platforms/firmata" "time" ) var bell = []byte{0x4, 0xe, 0xe, 0xe, 0x1f, 0x0, 0x4} var note = []byte{0x2, 0x3, 0x2, 0xe, 0x1e, 0xc, 0x0} var clock = []byte{0x0, 0xe, 0x15, 0x17, 0x11, 0xe, 0x0} var ...
// nya == client // 每一个ws连接生成一个结构体,其中包含了发送给自己消息的chan,通过goroutine监听并写给用户 // write goroutine监听用户ReadMessage信息,将其写入route.send或广播 package main import ( "time" ws "github.com/gorilla/websocket" "lo" ) type Nya struct { conn *ws.Conn recv chan []byte send []byte uuid int name string img string } const ( // 设置过...
/* * Copyright (c) 2020 Johannes Kohnen <jwkohnen-github@ko-sys.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless req...
package mongo import ( "goChat/Server/models" "goChat/Server/utils" "time" "gopkg.in/mgo.v2/bson" "gopkg.in/mgo.v2" ) // MessageRepository - Mongo implementation for IMessageRepository type MessageRepository struct { session *mgo.Session collection *mgo.Collection } const messageCollectionName = "Message...
package assoc import ( "bytes" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" ) // ValidatorSet defines type ValidatorSet struct { sdk.ValidatorSet store sdk.KVStore cdc *codec.Codec maxAssoc int addrLen int } var _ sdk.ValidatorSet = ValidatorSet{} // NewValidatorSet re...
package service import ( "bufio" "errors" "io" "log" "os" "path/filepath" "strings" ) // Undoes rename/reorganize operations. // Deletes the recovery file at the end func Recover(recoveryFilePath string) []error { file, err := os.Open(recoveryFilePath) if err != nil { log.Fatal(err) } defer file.Close()...
package main import ( "flag" "os" "github.com/eaciit/toolkit" . "eaciit/sebard/modules" ) var ( cfgFlag = flag.String("c", "", "-c='path to config file' | config file") hostFlag = flag.String("h", "", "-h=ip | ip") portFlag = flag.Int("p", 6789, "-p=port | port number") joinFlag = flag.Str...
package prop import ( "strings" ) type MiniPath struct { dir string } func NewMiniPath(dir string) *MiniPath { return &MiniPath{ dir: dir, } } func (obj *MiniPath) GetDir() string { items := strings.Split(obj.dir, "/") buf := make([]byte, 0, len(items)*2) for _, v := range items { if v != "" { buf = a...
package driveversion import ( "fmt" "github.com/scjalliance/drivestream/resource" ) // NotFound reports that a drive version could not be found within the // repository. type NotFound struct { Drive resource.ID Version resource.Version } // Error returns a string representation of the error. func (e NotFound)...
package crypto import ( "bytes" "crypto/cipher" "crypto/des" "errors" ) func DesEncrypt(src, key []byte, mode string) ([]byte, error) { switch mode { case "ecb": return ecbEncrypt(src, key) case "cbc": return desEncrpt(src, key) default: return ecbEncrypt(src, key) } } func DesDecrypt(crypted, key []b...
package suites import ( "bytes" "encoding/json" "fmt" "net/http" "testing" "github.com/stretchr/testify/require" "github.com/valyala/fasthttp" "github.com/authelia/authelia/v4/internal/duo" ) // DuoPolicy a type of policy. type DuoPolicy int32 const ( // Deny deny policy. Deny DuoPolicy = iota // Allow ...
package cryhel import ( "bytes" "crypto/aes" "crypto/cipher" "crypto/rand" "encoding/base64" "encoding/json" "errors" "fmt" "io" "net/url" "reflect" ) // any is purely semantic type any interface{} // Pointer is purely semantic type pointer interface{} func isPointer(value any) bool { if reflect.ValueOf...
package filter import ( "user/common" "github.com/astaxie/beego" "github.com/astaxie/beego/context" ) var OAuthFilter = func(ctx *context.Context) { access_token := ctx.Input.Query("access_token") beego.Debug("OAuthFilter >>>>>>> access_token : ", access_token) if access_token == "" { beego.Debug("OAuthFilte...
package ex112 import ( "fmt" "testing" ) func TestAdd(t *testing.T) { var tests = []struct { input int want string }{ {1, "{1}"}, {144, "{1 144}"}, {9, "{1 9 144}"}, } var x IntSet fmt.Println("===========") for _, test := range tests { x.Add(test.input) if string(x.String()) != test.want { ...
package authenticate import ( "crypto/cipher" "fmt" "net/url" "github.com/go-jose/go-jose/v3" "github.com/pomerium/pomerium/config" "github.com/pomerium/pomerium/internal/encoding" "github.com/pomerium/pomerium/internal/encoding/jws" "github.com/pomerium/pomerium/internal/sessions" "github.com/pomerium/pome...
/* Let's create a simple, surjective mapping from positive integers to Gaussian integers, which are complex numbers where the real and imaginary parts are integers. Given a positive integer, for example 4538, express it in binary with no leading 0's: 4538 base 10 = 1000110111010 base 2 Remove any trailing 0's: 1000...
package httputil import ( "strings" "net/http" "io/ioutil" "encoding/json" ) import ( "github.com/bww/go-rest" "github.com/gorilla/schema" ) var formDecoder *schema.Decoder func init() { formDecoder = schema.NewDecoder() formDecoder.IgnoreUnknownKeys(true) } func RequestEntity(req *rest.Request) ([]...
// Copyright 2023 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applica...
package ldap import ( "log" "github.com/go-ldap/ldap" ) func (s *LDAPStore) Delete(uid string) (err error) { for _, ls := range s.sources { err = ls.DeleteStaff(uid) if err != nil { return } } return } func (ls *ldapSource) DeleteStaff(uid string) (err error) { err = ls.Bind(ls.BindDN, ls.Passwd, fal...
package pie_test import ( "testing" "github.com/elliotchance/pie/v2" "github.com/stretchr/testify/assert" ) func TestGroupBy(t *testing.T) { type Room int const ( Kitchen Room = iota + 1 Bedroom Lounge ) type Item struct { room Room name string } var ( bed = Item{room: Bedroom, name: "bed...
package main import "testing" func TestFindRowColumn1(t *testing.T) { r, c := findRowColumn("BFFFBBFRRR") if r != 70 || c != 7 { t.Errorf("r, c is %d, %d; want 70, 7", r, c) } } func TestFindRowColumn2(t *testing.T) { r, c := findRowColumn("FFFBBBFRRR") if r != 14 || c != 7 { t.Errorf("r, c is %d, %d; want 1...
package health import ( "encoding/json" "fmt" "net/http" "net/http/httptest" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("WebService", func() { Describe("Check", func() { It("returns the data from the service health check", func() { ts := httptest.NewServer(http.HandlerFunc(f...
package main import ( "encoding/hex" "fmt" "io/ioutil" "log" "net" "os" "time" fcgiclient "github.com/tomasen/fcgi_client" ) const ( fpmSocket = "/var/run/php5-fpm.sock" phpTestFile = "/tmp/test.php" fpmWrapperSocket = "/tmp/fpm-wrapper.sock" fpmWrapperStderr = "/tmp/stderr" ) const ( testData1 = "e...
package main import ( "fmt" "os" "path/filepath" es "github.com/pkg/errors" ) /*TODO - implement proper formating (levels and final elements) - make dirTree write to *os.File, not just Print */ func main() { out := os.Stdout //where the output will be stored -> printed out if !(len(os.Args) == 2 || len(os.Ar...
/* * Copyright 2018, CS Systemes d'Information, http://www.c-s.fr * * 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 requir...
package main import ( "fmt" "regexp" ) // see: https://en.wikipedia.org/wiki/Emoji for emoji ranges var wordTokenRegex = regexp.MustCompile("((\\pL|\\pN|[\u20A0-\u20CF]|[\u2600-\u27BF])+|[\U0001F170-\U0001F9CF])") // TokenizeString returns the words in the passed in string, split by non word characters including e...
package minikube import ( "fmt" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/vmpath" "os/exec" "path" ) func kubectlCommand(cc *config.ClusterConfig, files []string, enable bool) *exec.Cmd { v := constants.DefaultKubernetesVersion if cc != nil { ...
package main const NGINX_BUILD_VERSION = "0.7.3" // nginx const ( NGINX_VERSION = "1.9.14" NGINX_DOWNLOAD_URL_PREFIX = "http://nginx.org/download" ) // pcre const ( PCRE_VERSION = "8.38" PCRE_DOWNLOAD_URL_PREFIX = "http://ftp.csx.cam.ac.uk/pub/software/programming/pcre" ) // openssl cons...
package catm import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00400101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:catm.004.001.01 Document"` Message *TerminalManagementRejectionV01 `xml:"TermnlMgmtRjctn"` } func (d *Documen...
package main import ( "bufio" "fmt" "os" "strconv" "strings" "regexp" ) func getInput() ([]string, int) { reader := bufio.NewReader(os.Stdin) text, _ := reader.ReadString('\n') text = strings.Replace(text, "\n", "", -1) n, _ := strconv.Atoi(text) text, _ = reader.ReadString('\n') text = strings.Replace(...
package main import "testing" func TestIdentifyComment(t *testing.T) { tests := []struct { path, trackID, smell string }{ {"a/b/c/ruby/d/e.md", "ruby", "d/e"}, {"a/b/c/go/d.md", "go", "d"}, } for _, test := range tests { trackID, smell := identifyComment("a/b/c", test.path) if trackID != test.trackID {...
package transport const ( // KeyS3BearerHeader is the legacy additional header used by Pydio Cells API // to authenticate the request to the tweaked S3 API. KeyS3BearerHeader = "X-Pydio-Bearer" ) var ( // RunEnvAwareTests flag permits easy switch off of all tests // that will not pass in basic environment, typi...
package openapi import ( "fmt" "time" ) func ToCreatedFormat(d time.Duration) string { sec := d - d.Truncate(time.Minute) min := d - d.Truncate(time.Hour) - sec hour := d - min - sec return fmt.Sprintf("%02.0f:%02.0f:%02.0f", hour.Hours(), min.Minutes(), sec.Seconds()) }
package helperfunctions import ( "strconv" "strings" "unicode" ) func TrimSpacesFromArray(title *[]string) { copy := *title for i := 0; i < len(*title); i++ { copy[i] = strings.TrimSpace(copy[i]) } *title = copy } func TrimSuffixesFromStringSlice(slice *[]string, suffixes ...string) { sliceCopy := *slice...
//Copyright (c) 2012 Brian Ketelsen //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute,...
package runtimes import "github.com/mee6aas/kyle/internal/pkg/runtime" // Take withdraws a runtime from the collection func Take() (r *runtime.Runtime, ok bool) { if len(runtimes) == 0 { return nil, false } for k, v := range runtimes { delete(runtimes, k) return v, true } return nil, false }
package controllers import ( "coludRenderDiscovery/discovery" "coludRenderDiscovery/models" "github.com/astaxie/beego" "github.com/astaxie/beego/orm" "strconv" ) type ManagerController struct { beego.Controller } func (c *ManagerController) Prepare() { c.Data["PROTOCOL_TYPE_REG_RENDER"] = discovery.PROTOCOL_T...
package user import ( "html/template" "net/http" "github.com/gin-gonic/gin" "github.com/pkg/errors" ) //go:generate go-bindata -pkg $GOPACKAGE login.html // Package cache of parsed templates (complete with base template association) var tmpl = map[string]*template.Template{} var page_data = struct { FormEndpo...
package main import "fmt" func Sum(nums ...int) int { total := 0 for _, num := range nums{ total += num } return total } /** * author: will fan * created: 2019/6/30 13:51 * description: */ func main() { total := Sum(1,2,3,4,5) fmt.Println("Total: ", total) }
package main import ( "fmt" "time" _ "github.com/go-sql-driver/mysql" "github.com/jinzhu/gorm" ) type TASKRESULTS struct { //Id int `gorm:"column:id"` TASKID string `grom:"column:task_id"` DATAMD5 string `gorm:"column:data_md5"` URL string `gorm:"column:url"` CONTENT string ...
package powerdns import ( "context" "encoding/json" "fmt" "github.com/jarcoal/httpmock" "log" "math/rand" "net/http" "regexp" "strings" "testing" ) func generateTestZone(autoAddZone bool) string { domain := fmt.Sprintf("test-%d.com", rand.Int()) if httpmock.Disabled() && autoAddZone { pdns := initialis...
package lettercasepermutation import ( "strconv" "strings" ) func backTrack( solutions map[string]int, candidates string, solution string, currIndex int, ) { if len(solution) > len(candidates) { return } if len(solution) == len(candidates) && strings.ToLower(solution) == strings.ToLower(candidates) { i...
package main import ( "crypto/tls" "fmt" "net/http" "os" "path" "strconv" "time" "github.com/rocinax/rigis/pkg/rigis" "github.com/sirupsen/logrus" "github.com/spf13/pflag" "github.com/spf13/viper" "golang.org/x/net/netutil" ) func init() { // *************** Server Default Setting *************** vipe...
package main import ( "fmt" "io/ioutil" "regexp" "strings" ) type Ini struct{} var iniKeyIdentifier = regexp.MustCompile(`^\[.*\]`) func (i Ini) Read(srcPath, dstPath string) (Source, Destination, error) { src := make(map[string]interface{}) dst := Destination{} readline := func(lines []string, dst *map[str...
package cli import ( "context" "flag" "fmt" "sort" "strings" "text/tabwriter" ) // Commands holds a mapping of sub command name to its implementation. type Commands map[string]Command var _ interface { // Compile time checks of desired interfaces implementation. Command SynopsisProvider DescriptionProvider ...
package utils type ResultObject struct { Code int Msg string Data interface{} } //仿静态方法 var Result = &ResultObject{} func (r *ResultObject) Success(msg string, data interface{}) map[string]interface{} { return map[string]interface{}{ "Code": 0, "Msg": msg, "Data": data, } } func (r *ResultObject) Fail(msg...
/* * Copyright © 2019-2022 Software AG, Darmstadt, Germany and/or its licensors * * SPDX-License-Identifier: Apache-2.0 * * 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://...
package mdutils import ( dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" blockstore "gx/ipfs/QmS2aqUZLJp8kF1ihE5rvDGE5LvmKDPnx32w9Z1BW9xLV5/go-ipfs-blockstore" offline "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFh...
/* Copyright 2020 The Crossplane Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, ...
package main import ( "io/ioutil" "os" "strings" "testing" ) const nginx = ` http { server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /usr/share/nginx/html; # Load configuration files for the default server block...
// 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 definition import ( "fmt" ) const ( // CassandraService const CassandraService = "cassandra" // CassandraPort const CassandraPort = "9042" // CassandraDo...
package main func main() { // demo 1 ch1 := make(chan int, 1) ch1 <- 1 ch1 <- 2 // 通道已满,因此这里会阻塞 // demo 2 ch2 := make(chan int, 1) elem, ok := <-ch2 // 通道已空,因此这里会阻塞 _,_ = elem, ok // demo 3 var ch3 chan int ch3 <- 1 // 通道的值为nil,发送操作和接受操作都会永久处于阻塞状态 }
package commands import ( "crypto/tls" "fmt" "os" "reflect" "time" "github.com/argoproj/pkg/errors" "github.com/argoproj/pkg/stats" log "github.com/sirupsen/logrus" "github.com/skratchdot/open-golang/open" "github.com/spf13/cobra" "golang.org/x/net/context" "k8s.io/client-go/kubernetes" _ "k8s.io/client-...
package main import ( "bufio" "fmt" "os" ) func main() { scanner := bufio.NewScanner(os.Stdin) scanner.Split(bufio.ScanLines) var a int scanner.Scan() fmt.Sscanf(scanner.Text(), "%d", &a) for i := 0; i < a; i++ { scanner.Scan() s:=scanner.Text() if len(s) > 11 && s[:10] == "simon says" { fmt.Prin...
package main import ( "path/filepath" "os" "path" "strings" "io/ioutil" "regexp" "net/http" "errors" "fmt" "log" "time" ) var ( reg = regexp.MustCompile(`!\[.*]\((?P<url>.*)\)`) record map[string]string count, sum int64 ) func main() { for { count = 0 sum = 0 record = make(map[string]string) f...
package main import ( "os" ) // fileExists returns true iff the path name is a file (and not a directory or non-existant). func fileExists(name string) bool { fi, err := os.Stat(name) if err != nil { return false } if fi.IsDir() { return false } return true }
// 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 main const PAGE = `<!DOCTYPE html> <html lang='en'> <head> <meta charset='utf-8'> <meta name='viewport' content='width=device-width'> <title>Hautomo</title> <script src='https://apis.google.com/js/platform.js' async defer></script> <meta name='google-signin-client_id' content='47418486199...
package models type Qrcode struct { Id string `db:"id"` Index int `db:"index"` }
package controllers import ( "bytes" "fmt" "net/http" "net/http/httptest" "strings" "testing" "time" ) var prepend = "/api/v1" type PersonResponse struct { ID int `json:"id"` Name string `json:"name"` Age int `json:"age"` CreatedAt time.Time `json:"created_at"` UpdatedAt ...
// Copyright (c) 2020 Tailscale Inc & 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 policy import ( "testing" "github.com/google/go-cmp/cmp" "tailscale.com/wgengine/filter" ) type PortRange = filter.PortRange type IPPo...