text
stringlengths
11
4.05M
package main import ( "crypto/tls" "io" "math/rand" "net" "os" "sync" "time" ) const TIMEOUT = 10 * time.Second type Proxy struct { LocalAddr string TlsServerConfig *tls.Config RemoteAddr string TlsClientConfig *tls.Config remoteTcpAddr *net.TCPAddr } func (p *Proxy) StartLocalServer() { ...
package cmd_test import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" "os" "os/exec" "runtime" homedir "github.com/mitchellh/go-homedir" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" "github.com/RackHD/voyager-cli/cmd" ) var _ = Describe("Comman...
package main import "fmt" func main() { defer fmt.Println("I want to close a file") fmt.Println("Hello") panic("There is a problem") fmt.Println("Bye") }
package fcrypto import ( "bytes" "io/ioutil" "os" "strings" "testing" "github.com/stretchr/testify/assert" ) const secret = "secret" const file = "testdata/test.txt" func TestEncrypt(t *testing.T) { SaveFile(bytes.NewBufferString("foobar"), "testdata/test.txt", "test") _, err := os.Stat("testdata/test.txt")...
package main // // Flags are based on python3.3-config --cflags and --ldflags // #cgo darwin CFLAGS:-I/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/include/python3.3m -I/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/include/python3.3m -fno-common -dynamic -DNDEBUG -...
package main import ( "github.com/enjoy-web/ehttp" "github.com/enjoy-web/ehttp/examples/restful-demo/api" "github.com/enjoy-web/ehttp/examples/restful-demo/model" ) func main() { conf := &ehttp.Config{ Schemes: []ehttp.Scheme{ehttp.SchemeHTTP, ehttp.SchemeHTTPS}, BasePath: "/dev", Versi...
package utils import ( "fmt" "math" ) // Welcome to the machine // TODO: // - introduce state variable: unstarted, running, halted, terminated // - replace first, second, third with an []Parameter type Machine struct { Name string ip uint64 rbp uint64 memory [100000]int64 halted ...
// Copyright (c) 2015 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. //go:build generate // +build generate package main import ( "fmt" "log" "os" "strings" "github.com/btcsuite/btcd/btcjson" "github.com/btcsuite/btcwallet/internal/rp...
package yaziya import ( "testing" ) var validations = []struct { input float64 expected string }{ {5, "beş"}, {13, "onüç"}, {25, "yirmibeş"}, {587, "beşyüzseksenyedi"}, {1458, "bin dörtyüzellisekiz"}, {14580, "ondört bin beşyüzseksen"}, {145800, "yüzkırkbeş bin sekizyüz"}, {1458001, "bir milyon dörtyüze...
package json import ( "io" jsoniter "github.com/json-iterator/go" ) var jsonConfig = jsoniter.ConfigCompatibleWithStandardLibrary // Marshal json marshal func Marshal(v interface{}) ([]byte, error) { return jsonConfig.Marshal(v) } // Unmarshal json unmarshal func Unmarshal(data []byte, v interface{}) error { r...
// Copyright (c) 2019 Chair of Applied Cryptography, Technische Universität // Darmstadt, Germany. All rights reserved. This file is part of go-perun. Use // of this source code is governed by a MIT-style license that can be found in // the LICENSE file. package sync_test import ( "testing" "time" "github.com/str...
package lv1_character_go import "strings" func NewCharacter() *Character { return &Character{ rt: &Type{"R", "T", 0}, cf: &Type{"C", "F", 0}, jm: &Type{"J", "M", 0}, an: &Type{"A", "N", 0}, } } type Character struct { rt, cf, jm, an *Type } // bool(reverse) func (c *Character) Select(name string) (*Type,...
package compliance import ( "fmt" "net/http" "os" "time" "github.com/goji/httpauth" log "github.com/sirupsen/logrus" "github.com/facebookgo/inject" "github.com/stellar/gateway/compliance/config" "github.com/stellar/gateway/compliance/handlers" "github.com/stellar/gateway/crypto" "github.com/stellar/gatewa...
package main import ( "fmt" "log" "os" "github.com/awslabs/aws-sdk-go/aws" "github.com/awslabs/aws-sdk-go/gen/rds" ) var region = "us-west-2" // Connect will provide a valid RDS client func Connect() *rds.RDS { creds := aws.Creds(os.Getenv("AWS_ACCESS_KEY"), os.Getenv("AWS_SECRET_KEY"), "") // HL return rds....
// 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...
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at // 2020-04-09 09:41:37.367371 +0700 +07 m=+0.032412113 package docs import ( "bytes" "encoding/json" "strings" "github.com/alecthomas/template" "github.com/swaggo/swag" ) var doc = `{ "schemes": {{ marshal .Schemes ...
package main import "fmt" var ( n int i int j int a int s string ) //Cometario de Fibo func fibo( n int) int { if n == 0 || n == 1 { return n } else { return fibo( n - 1 ) + fibo( n - 2) } } func main() { i:= 10; fmt.Println("Bienvenidos CUCEI...
package main import ( "fmt" ) func main() { a := incrementor() b := incrementor() fmt.Println("incrementor 'a' :: ") fmt.Println("\t", a()) fmt.Println("\t", a()) fmt.Println("\t", a()) fmt.Println("\t", a()) fmt.Println("\t", a()) fmt.Println("incrementor 'b' :: ") fmt.Pri...
package data import ( "context" "encoding/json" "fmt" "github.com/Kamva/mgm/v3" "go.mongodb.org/mongo-driver/bson" "log" ) // UpsertThreeWordPhraseFrequency inserts or updates the 3 word phrase frequencies in the database with the given phraseFrequency map // If it's a new phrase it's frequency is set to the gi...
// 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 entities type BirdVoteGateway interface { AddVote(int) (int, error) }
package handlers import ( "log" "net/http" "net/http/httptest" "os" "strings" "testing" "github.com/gorilla/mux" "github.com/saurabmish/Coffee-Shop/data" "github.com/stretchr/testify/assert" ) func DeleteRouter() *mux.Router { l := log.New(os.Stdout, "[TEST] Coffee shop API service ", log.LstdFlags) v := ...
package fileview import ( "github.com/scjalliance/drivestream/commit" "github.com/scjalliance/drivestream/resource" ) // Data holds data about a file view. type Data struct { File resource.ID Drive resource.ID Commit commit.SeqNum Version resource.Version }
// Copyright 2017 The OPA Authors. All rights reserved. // Use of this source code is governed by an Apache2 // license that can be found in the LICENSE file. package configmap import ( "context" "encoding/json" "fmt" "hash/fnv" "sort" "strings" "time" "strconv" "github.com/open-policy-agent/kube-mgmt/pkg/...
package main import "fmt" type ListNode struct { Val int Next *ListNode } func main() { head := ListNode{4, &ListNode{5, &ListNode{6, &ListNode{7, nil}}}} fmt.Println(hasCycle(&head)) } func hasCycle(head *ListNode) bool { if head == nil || head.Next == nil { return false } first := head second := head ...
func sortedSquares(A []int) []int { size := len(A) res := make([]int, size) l, r, k := 0, size - 1, size - 1 for ; l <= r; { if A[l] + A[r] < 0 { res[k] = A[l] * A[l] l++ } else { res[k] = A[r] * A[r] r-- } k-- } ret...
package main import "fmt" func main() { var a int //每个变量有两层含义:变量的内存,变量的地址 a = 10 fmt.Printf("a=%d \n", a) fmt.Printf("a = %v \n", &a) var p *int p = &a fmt.Printf("&a = %v,p = %v \n", &a, p) *p = 666 //*p操作的不是p的内存,而是p所指向的地址的内存 fmt.Printf("*p = %v,a = %v ,p=%v\n", *p, a, p) var b *int b = nil fmt.Pri...
package server import ( "net/http" "strconv" "github.com/empirefox/esecend/cerr" "github.com/empirefox/esecend/front" "github.com/empirefox/esecend/utils" "github.com/empirefox/reform" "github.com/gin-gonic/gin" ) func (s *Server) GetProductsBundle(c *gin.Context) { bundle := make(map[string][]reform.Struct)...
package main import ( "fmt" "reflect" ) type Person struct { Name string Address []string } func main() { var a, b []Person a = []Person{ Person{ Name: "a", Address: []string{"A", "B"}, }, Person{ Name: "b", Address: []string{"C", "D"}, }, } b = []Person{ Person{}, // Person{...
package consul import ( "fmt" consulAPI "github.com/hashicorp/consul/api" consulWatch "github.com/hashicorp/consul/api/watch" ) // ClientInterface defines the Client of Consul // Registration/Registration service to Consul // Listening to the service in Consul type ClientInterface interface { Wait() ...
// 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 models type Subreddit struct { Kind string `json:"kind"` Data SubredditData `json:"data"` } type SubredditData struct { UserFlairBackgroundColor string `json:"user_flair_background_color"` SubmitTextHtml string `json:"submit_text_html"` RestrictPosting bool `jso...
package mempid import ( "os" "path" ) var ( _pm *ProgMutex ) func NewProgMutex(keyName string) *ProgMutex { key := genKey(keyName) return &ProgMutex{AppName: path.Base(os.Args[0]), key: key} } /* GetPid return value of int: 0 not running. >0 progress is running, and the return value is the PID of progress....
/* Arild just turned 1 year old, and is currently learning how to count. His favorite thing to count is how many mouthfuls he has in a meal: every time he gets a bite, he will count it by saying the number out loud. Unfortunately, talking while having a mouthful sometimes causes Arild to mumble incomprehensibly, maki...
package Service import ( "Work_5/DAO" "Work_5/object" ) //Service修改提问函数 func UpdataQuestion(user *object.User, question *object.Question) object.ErrMessage { //获得数据库连接 db, err := DAO.DataBaseInit() if err.IsErr { return err } //判断修改提问的用户,是否是这个问题的提出者 isQuestioner, _ := DAO.IsQuestioner(user, *question, db)...
/* Copyright 2018 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 main import ( "testing" ) func TestMinStack_push(t *testing.T) { type fields struct { minStack []int minValues []int } type args struct { val int } tests := []struct { name string fields fields args args minValues int }{ { "Push a value", fields{[]int{2, 3, 4}, []int{2, ...
package bslib import ( "time" ) const sqlCreateTableItems = ` CREATE TABLE IF NOT EXISTS items ( item_id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR NOT NULL, icon VARCHAR NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, deleted BOOLEAN ...
package boltdb type Writer struct { store *Store } func (w *Writer) Write(key, val []byte) (err error) { tx, err := w.store.db.Begin(true) if err != nil { return } // 原子性保证,要么成功 commit 提交事务, 要么失败 rollback 回滚事务 defer func() { if err == nil { err = tx.Commit() } else { _ = tx.Rollback() } }() buc...
package container import ( "fmt" "os" "syscall" "time" "github.com/criyle/go-sandbox/pkg/unixsocket" ) // Ping send ping message to container, wait for 3 second before timeout func (c *container) Ping() error { c.mu.Lock() defer c.mu.Unlock() // avoid infinite wait (max 3s) const pingWait = 3 * time.Second...
package lib import ( "math/rand" "time" "github.com/nsf/termbox-go" ) // The set of tile types const ( _ int = iota TileFloor TileWall TileOutside TileBox TileChest TileTrapdoor TileMerchant ) // A Tile is a single block in the world type Tile interface { Render(x, y int) Passable() bool Description(...
package typec // TypeC ... type TypeC struct{}
// Copyright 2019-2023 The sakuracloud_exporter 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 appl...
package font type Style string const StyleNormal Style = "normal" const StyleItalic Style = "italic" const StyleOblique Style = "oblique" const StyleInitial Style = "initial" const StyleInherit Style = "inherit" func (s Style) String() string { return string(s) }
package models import ( "fmt" "github.com/go-chi/chi/v5" "html/template" "log" "net/http" "strconv" "strings" "time" ) type Comment struct { ID int64 `json:"id"` Comment string `json:"comment"` } func CreateComment(w http.ResponseWriter, r *http.Request){ param := chi.URLParam(r, "id") id, err := strco...
package main import ( "fmt" ) func main() { m := make(map[string]int) m["key1"] = 1 m["key2"] = 2 fmt.Println("map: ", m) var1 := m["key1"] fmt.Println("var1: ", var1) var1 = m["key2"] fmt.Println("var1: ", var1) fmt.Println("len: ", len(m)) delete(m, "key2") fmt.Println("map: ", m) /* the "_, c...
/* Given an integer array nums that does not contain any zeros, find the largest positive integer k such that -k also exists in the array. Return the positive integer k. If there is no such integer, return -1. Example 1: Input: nums = [-1,2,-3,3] Output: 3 Explanation: 3 is the only valid k we can find in the array...
package envconfig import ( "os" "github.com/vrischmann/envconfig" ) // Init the given config. Supports also envs prefix if set. func Init(conf interface{}) error { envPrefix := os.Getenv("ENVS_PREFIX") return envconfig.InitWithPrefix(conf, envPrefix) }
package tccp type templateParams struct { DockerVolumeResourceName string MasterInstanceResourceName string }
package xchango import ( "strconv" "strings" "testing" "github.com/stretchr/testify/assert" ) func TestBuildCalendarDetailRequest(t *testing.T) { config := ExchangeConfig{ MaxFetchSize: 101, } xchang, err := NewExchangeClient(config) if err != nil { t.Fatalf("%+v", err) } appoints := []Appointment{ ...
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. package api import ( "testing" "github.com/Azure/aks-engine/pkg/api/common" "github.com/blang/semver" . "github.com/onsi/gomega" ) func TestInvalidVersion(t *testing.T) { RegisterTestingT(t) invalid := []string{ ...
package repository import ( entity "github.com/Surafeljava/Court-Case-Management-System/Entity" notificationuse "github.com/Surafeljava/Court-Case-Management-System/notificationUse" "github.com/jinzhu/gorm" ) // //NotificationRepositoryImpl struct create connection to database and implements notification repo type...
package search import ( "github.com/myProj/scaner/new/include/textSearchAndExtract/extract" "github.com/myProj/scaner/new/include/textSearchAndExtract/extract/docx" "github.com/myProj/scaner/new/include/textSearchAndExtract/extract/pptx" "github.com/myProj/scaner/new/include/textSearchAndExtract/extract/vsdx" "gi...
package ftp import ( "github.com/bearname/videohost/internal/common/util" "github.com/jlaffaye/ftp" "io" ) type Client struct { client *ftp.ServerConn } func NewFtpConnection(address string, username string, password string) *Client { client, err := ftp.Dial(address) if err != nil { return nil } if err = ...
package virtual_security // ExchangeType - 市場種別 type ExchangeType string const ( ExchangeTypeUnspecified ExchangeType = "" // 未指定 ExchangeTypeStock ExchangeType = "stock" // 株式現物 ExchangeTypeMargin ExchangeType = "margin" // 株式信用 ExchangeTypeFuture ExchangeType = "future" // 先物 ) // OrderS...
package providerquerymanager import ( "context" "errors" "reflect" "sync" "testing" "time" "gx/ipfs/QmYJ48z7NEzo3u2yCvUvNtBQ7wJWd5dX2nxxc7FeA6nHq1/go-bitswap/testutil" "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" ...
package main import ( "io" "net/http" ) func s(res http.ResponseWriter, req *http.Request) { io.WriteString(res, "Snop Doggy Doggy Dogg") } func d(res http.ResponseWriter, req *http.Request) { io.WriteString(res, "Pussy Pussy Cat Dolls") } func main() { http.HandleFunc("/snoop", s) http.HandleFunc("/dolls", d...
// Copyright 2022 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 controllers import ( "encoding/json" "time" //"time" "tokensky_bg_admin/conf" "tokensky_bg_admin/enums" "tokensky_bg_admin/models" ) type HashrateSendBalanceRecordController struct { BaseController } func (c *HashrateSendBalanceRecordController) Prepare() { //先执行 c.BaseController.Prepare() //如果一个C...
package auth import ( "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" pbAuth "Open_IM/pkg/proto/auth" "Open_IM/pkg/utils" "google.golang.org/grpc" "net" "strconv" "strings" ) type rpcAuth struct { rpcPort int rpcRegisterName string etcdSchema string etc...
package tarot import ( "testing" ) func TestAllCards(t *testing.T) { cards := allCards() if len(cards) != 78 { t.Errorf("allCards should return 78 cards\n") } } func TestCompareCards(t *testing.T) { cards := make(map[Color][]Card) for col, nb := range nbCardsPerColor { if _, ok := cards[col]; !ok { card...
package otf import ( "io" ) func headParser(_ SFNT, r *io.SectionReader) Table { return ReadTable(r, new(Head)) } func (_ *Head) Tag() TAG { return TAG_HEAD } func (t *Head) Bytes() []byte { return DumpBigEndian(t) } func (t *Head) SetUp(f SFNT) error { t.CheckSumAdjustment = 0 // FIXME: it must be implement...
package functions import ( "encoding/json" "fmt" "strings" igrpc "github.com/direktiv/direktiv/pkg/functions/grpc" "github.com/direktiv/direktiv/pkg/model" "github.com/mitchellh/hashstructure/v2" hash "github.com/mitchellh/hashstructure/v2" ) func SanitizeLabel(s string) string { s = strings.TrimPrefix(s, "/...
package main import ( "bytes" "fmt" "log" "os" "path/filepath" "regexp" "strings" "gopkg.in/yaml.v3" ) const ( // raw github source URL. sourceURL = "https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/" // directory entry point for parsing. entryPoint = "library" muta...
package dushengchen /** Submission: https://leetcode.com/submissions/detail/375851921/ Runtime: 0 ms, faster than 100.00% of Go online submissions for Plus One. Memory Usage: 2 MB, less than 93.94% of Go online submissions for Plus One. */ func plusOne(digits []int) []int { before := 1 for i := len(digits) - 1; i ...
package arp_test import ( "bytes" "encoding/binary" "github.com/google/gopacket/pcap" "github.com/iesreza/arp" "github.com/iesreza/gutil/log" "github.com/iesreza/netconfig" "net" "testing" "time" ) func TestWhoIs(t *testing.T) { config := netconfig.GetNetworkConfig() handler, err := pcap.OpenLive(config.I...
package httpclient import "fmt" type Error struct { Code int Message string } func (e *Error) Error() string { return fmt.Sprintf("httpclient error. Code: %v detail: %s", e.Code, e.Message) }
package es import ( "syscall" "time" "unsafe" ) // EVERYTHINGUSERAPI DWORD EVERYTHINGAPI Everything_GetNumFileResults(void); var dllEverythingGetNumFileResults *syscall.LazyProc func EverythingGetNumFileResults() (uint32, error) { r1, _, err := dllEverythingGetNumFileResults.Call() return uint32(r1), checkErr(r...
package main import ( "bufio" "fmt" "log" "net" "strconv" "strings" ) type FTPConn struct { cwd string control *net.TCPConn controlReader *bufio.Reader controlWriter *bufio.Writer data FTPDataSocket } func (ftpConn *FTPConn) WriteMessage(messageFormat string, v ...interface{}) (wr...
package ctx import ( "fmt" "os" "os/exec" "path/filepath" "github.com/operator-framework/operator-lifecycle-manager/test/e2e/util" appsv1 "k8s.io/api/apps/v1" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1" apiextensionsv1 "k8s.i...
package backends import ( _ "io" ) /* Config implement config interface for common, c, cpp, golang */ type Config struct { // common config ConfigCommonImpl // config for c and cpp CConfigImpl // config for golang GolangConfigImpl } func NewConfig() *Config { ret := &Config{} ret.Init() return ret } fu...
package redfish import ( "fmt" "net/http" aerror "opendev.org/airship/airshipctl/pkg/errors" ) type RedfishClientError struct { aerror.AirshipError } func NewRedfishClientErrorf(format string, v ...interface{}) error { e := &RedfishClientError{} e.Message = fmt.Sprintf(format, v...) return e } type RedfishC...
package main import ( "coordinator/scheduler" "flag" "fmt" "net" "net/http" "net/rpc" "types" "github.com/golang/glog" ) const ( clientPort = "4321" ) var ( pendingPodCh chan types.InterPod ) func init() { pendingPodCh = make(chan types.InterPod, 10) } type Server int func (t *Server) RegisterCluster(...
package main import ( "flag" "time" ) var appName = "crypto-tray-ticker" var ( blinkOnUpdate = flag.Bool("blink", false, "blink on update") updatesDelay = flag.Duration("updates-delay", 5*time.Second, "Delay between updates") tokensLimit = flag.Int("tokens-limit", 20, "limit of tokens in menu") fileName ...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //171. Excel Sheet Column Number //Related to question Excel Sheet Column Title //Given a column title as appear in an Excel sheet, return its correspo...
package main import ( "log" "encoding/json" "database/sql" "fmt" "github.com/lib/pq" "github.com/streadway/amqp" ) const ( host = "localhost" port = 5432 user = "postgres" password = "password" dbname = "golang_pub_sub" ) type AutoGenerated struct { Offers []struct { CmOfferID str...
//go:build adalnk && cgo // +build adalnk,cgo /* * Copyright © 2018-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 ob...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2020-08-16 13:16 # @File : buble_sort.go # @Description : # @Attention : */ package sort import "testing" func TestBubbleSort(t *testing.T) { array:=[]int{1,3,0,2,8,4,9,5} BubbleSort(array) println(1) }
package main type Party struct { Rooms map[*Room]bool } var EstimationParty = &Party{ Rooms: make(map[*Room]bool), }
package main import ( "fmt" "testing" ) func TestIsBipartite(t *testing.T) { ans := IsBipartite([][]int{{1}, {0}, {4}, {4}, {2, 3}}) fmt.Println(ans) }
package webserver import ( "log" "net/http" "strings" "github.com/c12o16h1/shender/pkg/cache" "github.com/pkg/errors" ) const ( HEADER_ACCEPT_ALL = "*/*" HEADER_ACCEPT_HTML = "text/html" ) var ( ERR_NOT_CACHED = "not cached" maxExtensionLengt = 4 // Max length of file extension html = ...
package main import ( "fmt" "log" "os" "path/filepath" "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/werf/logboek" "github.com/werf/werf/cmd/werf/build" "github.com/werf/werf/cmd/werf/ci_env" "github.com/werf/werf/cmd/werf/cleanup" "github.com/werf/werf/cmd/werf/compose" "github.com/...
package iwebsocket /* IRequest 接口: 实际上是把客户端请求的链接信息 和 请求的数据 包装到了 Request里 */ type IRequest interface { GetConnection() IConnection //获取请求连接信息 GetMessage() IMessage //获取请求消息的数据 }
package service import ( "cherry/weather" "net/http" ) type CherryService struct { } func (c *CherryService) WeatherService(w http.ResponseWriter, r *http.Request) { data := weather.GetWeatherData() w.Write([]byte(data)) }
package refImpl import ( "context" "encoding/json" "fmt" "github.com/go-ocf/cloud/cloud2cloud-connector/service" storeMongodb "github.com/go-ocf/cloud/cloud2cloud-connector/store/mongodb" "github.com/go-ocf/cloud/resource-aggregate/cqrs/eventbus/nats" "github.com/go-ocf/cloud/resource-aggregate/cqrs/eventstore...
package config import ( "github.com/spf13/viper" ) // InstructorWorkerConfig specified a worker destination service type InstructorWorkerConfig struct { // Human readable name for the worker target Alias string // IP or DNS resolvable hostname of the worker Adress string // TCP port of the worke...
// +build !darwin package crypt import ( "testing" "github.com/stretchr/testify/assert" ) func Test_crypt_PasswordIsCrypted(t *testing.T) { tests := []struct { name string password string want bool }{ { name: "bcrypt", password: "$2b$04$123465789012345678901uac5A8egfBuZVHMrDZsQzR96IqN...
package main import ( "github.com/gin-gonic/gin" _"github.com/jinzhu/gorm/dialects/mysql" "ginSession/controller" _"ginSession/model" "ginSession/model" "ginSession/proto" "ginSession/dao" ) func main() { defer model.DB.Close() r :=gin.Default() r.Static("/static","./static") r.LoadHTMLGlob("./templates/*"...
package main import ( "net/http" "fmt" ) func main(){ mux := http.NewServeMux() //mux.HandleFunc("/hi",sayHi) mux.Handle("/hi2", http.HandlerFunc(sayHi)) http.ListenAndServe(":9000",mux) } func sayHi(response http.ResponseWriter, r *http.Request) { response.Header().Set("content-type","application/json") ...
package main import "github.com/aiquestion/go-simplejson" type DevicePropOrEvent struct { Name string `json:"name"` Value string `json:"value"` TimeStamp int64 `json:"timestamp"` } type SdsData struct { Did string `json:"did"` Type string `json:"type"` Key string `json:"key"` Time int64 `json...
package ovftool import ( "errors" "fmt" "io/ioutil" "log" "os" "os/exec" "path" "strings" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" ) const ( Separator = string(os.PathSeparator...
package subscription import ( "github.com/dennor/go-paddle/events/types" "github.com/dennor/phpserialize" ) const PaymentSucceededAlertName = "subscription_payment_succeeded" // PaymentSucceeded refer to https://paddle.com/docs/subscriptions-event-reference/#subscription_payment_succeeded type PaymentSucceeded str...
package ds /** * * A bus has n stops numbered from 0 to n - 1 that form a circle. We know the distance between all pairs of neighboring stops where distance[i] is the distance between the stops number i and (i + 1) % n. The bus goes along both directions i.e. clockwise and counterclockwise. Return the shortest...
package lcd import ( "fmt" "net/http" "github.com/gorilla/mux" "github.com/irisnet/irishub/app/protocol" "github.com/irisnet/irishub/app/v1/service" "github.com/irisnet/irishub/client/context" "github.com/irisnet/irishub/client/utils" "github.com/irisnet/irishub/codec" sdk "github.com/irisnet/irishub/types" ...
package sfapi import ( "encoding/json" "errors" "fmt" "strings" "time" log "github.com/Sirupsen/logrus" ) func (c *Client) ListVolumesForAccount(listReq *ListVolumesForAccountRequest) (volumes []Volume, err error) { response, err := c.Request("ListVolumesForAccount", listReq, newReqID()) if err != nil { lo...
package config import ( "github.com/BurntSushi/toml" "log" "os" "sync" ) type Config struct { App App Database Database Redis Redis } type App struct { Appname string Port string } type Database struct { Host string Port string Database string User string Password string SSL ...
package couchdb var ( db *CouchDatabase ) func Instance() *CouchDatabase { if db == nil { couchDBDef := GetCouchDBDefinition() couchInstance, err := CreateCouchInstance(couchDBDef.URL, couchDBDef.Username, couchDBDef.Password, couchDBDef.MaxRetries, couchDBDef.MaxRetriesOnStartup, couchDBDef.Requ...
package metadata import ( "gopkg.in/yaml.v2" "log" "os" ) func Build(bytes []byte) Config { cluster := serialize(bytes) return cluster } func serialize(metadata []byte) Config { cluster := Config{} err := yaml.Unmarshal(metadata, &cluster) if err != nil { log.Fatalf("-- error %v", err) os.Exit(1) } ...
package workload import ( "context" "fmt" "io" "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" "github.com/projecteru2/cli/cmd/utils" corecluster "github.com/projecteru2/core/cluster" corepb "github.com/projecteru2/core/rpc/gen" coreutils "github.com/projecteru2/core/utils" ) type controlWorkloadsO...
package v1alpha2 import ( "testing" next "github.com/devspace-cloud/devspace/pkg/devspace/config/versions/v1alpha3" "github.com/devspace-cloud/devspace/pkg/util/log" "github.com/devspace-cloud/devspace/pkg/util/ptr" ) func TestSimple(t *testing.T) { oldConfig := &Config{ Cluster: &Cluster{ CloudProvider: p...