text
stringlengths
11
4.05M
package util import ( "regexp" "strings" ) type StringMatcher func(haystack, needle string) bool var All StringMatcher = func(haystack, needle string) bool { return true } var Equal StringMatcher = func(haystack, needle string) bool { return haystack == needle } var Contains StringMatcher = func(haystack, need...
// Copyright 2020 The VectorSQL Authors. // // Code is licensed under Apache License, Version 2.0. package tcp import ( "executors" ) type QueryState struct { result *executors.Result } func (state *QueryState) SetExecutorResult(r *executors.Result) { state.result = r } func (state *QueryState) Empty() bool { ...
package main import ( "database-manager/api" "database-manager/collections" "database-manager/configuration" "fmt" "log" "net/http" "time" ) func main() { httpRouter := api.NewRouter() configuration.InitConfig() srv := &http.Server{ Handler: httpRouter, Addr: ":" + fmt.Sprint(configuration.Config.HTT...
package gitlabClient import ( "github.com/xanzy/go-gitlab" "regexp" "strconv" ) func (git *GitLab) ParseWeight(title string) int { var rgx = regexp.MustCompile(`\[(.*?)\]`) rs := rgx.FindStringSubmatch(title) if len(rs) == 0 { return 0 } weight, err := strconv.Atoi(rs[1]) if err != nil { return 0 } ...
package p1 // func TestSum(t *testing.T) { // tests := []struct { // Input string // Result int // }{ // { // Input: "1122", // Result: 3, // }, // { // Input: "1111", // Result: 4, // }, // { // Input: "1234", // Result: 0, // }, // { // Input: "91212129", // Result: 9...
package LeetCode import ( "fmt" ) func Code300() { num := lengthOfLIS([]int{1, 3, 6, 7, 9, 4, 10, 5, 6}) fmt.Println(num) } /** 给定一个无序的整数数组,找到其中最长上升子序列的长度。 示例: 输入: [10,9,2,5,3,7,101,18] 输出: 4 解释: 最长的上升子序列是 [2,3,7,101],它的长度是 4。 说明: 可能会有多种最长上升子序列的组合,你只需要输出对应的长度即可。 你算法的时间复杂度应该为 O(n2) 。 进阶: 你能将算法的时间复杂度降低到 O(n log ...
package main import ( "errors" "fmt" "github.com/afex/hystrix-go/hystrix" "time" ) /** 判断是否会触发熔断 其实可以看到结果很明显,当第100次的时候,由于我们此时流量已经大于等于100了,所以已经突破了请求阀值,而且我们的异常量此时是10/100=10,然后可以看到的就是此时已经等于等于阀值了,所以会触发熔断 */ func main() { hystrix.ConfigureCommand("my_command", hystrix.CommandConfig{ RequestVolumeThreshold: 100, S...
package kustomize import ( "github.com/rancher/wrangler/pkg/data" "github.com/rancher/wrangler/pkg/summary" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "sigs.k8s.io/cli-utils/pkg/kstatus/status" ) func init() { summary.Summarizers = append(summary.Summarizers, KStatusSummarizer) } func KStatusSummarizer...
package types type ImageNameTag struct { ImageConfigName string ImageName string LocalRegistryImageName string ImageTag string }
package main import "sync" func main66() { var wg sync.WaitGroup wg.Add(1) go func() { wg.Add(1) //来不及设置 //defer wg.Done() println("hi!") }() wg.Wait() println("exit.") }
package watcher import "fmt" type QaBlinkStatusCode int const ( STABLE QaBlinkStatusCode = iota UNSTABLE FAILED UNKNOWN DISABLED ) type QaBlinkState struct { StatusCode QaBlinkStatusCode Score uint8 Pending bool } type QaBlinkJob interface { Update() State() QaBlinkState Id() string } func (cod...
// Package hamming is a package to implement the calculation of dna package hamming import "errors" // Distance calculates the hamming distance func Distance(a, b string) (dis int, err error) { if len(a) != len(b) { return 0, errors.New("Not Equal length") } for index := 0; index <= len(a)-1; index++ { if a[i...
// Copyright 2019 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package kernelmeter provides a mechanism for collecting kernel-related // measurements in parallel with the execution of a test. // // Several kernel quantities (e.g page ...
// Copyright 2018 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package solutions func maxProfit(prices []int) int { buy, sell := -int(^uint(0) >> 1) - 1, -int(^uint(0) >> 1) - 1 nothing := 0 for i := 0; i < len(prices); i++ { temp := nothing nothing = max(nothing, sell) buy = max(buy, temp - prices[i]) sell = buy + prices[i] } ...
package Reorganize_String func reorganizeString(S string) string { n := len(S) if n <= 1 { return S } maxCnt := 0 cnt := [26]int{} for _, c := range S { cnt[c-'a']++ if cnt[c-'a'] > maxCnt { maxCnt = cnt[c-'a'] } } if maxCnt > (n+1)/2 { return "" } result := make([]byte, n) oddIndex, evenInd...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package fingerprint // FirmwareFilePath is the directory that hold fingerprint MCU firmware files. const FirmwareFilePath = "/opt/google/biod/fw" // FirmwareFilePattern pro...
package main import ( "fmt" "math/rand" "net/http" "time" ) const RandomUpperThreshold int = 5 func concurrentHandler(w http.ResponseWriter, r *http.Request) { receiver := make(chan string) rand.Seed(time.Now().UnixNano()) go searchOnFacebook(receiver) go searchOnGoogle(receiver) go searchOnTwitter(receive...
// Copyright 2016 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package main import ( "io" "net/url" "strings" "golang.org/x/net/html" ) // Function to retrieve a list of attribute values in HTML5 tags. // Example: getAllTagAttr(map[string]string{"a": "href",}, File) retrieves // all values of attribute href for all "a" tags in the document. // TODO: This parser implementat...
package taskqueue import ( "github.com/RichardKnop/machinery/v1" "github.com/RichardKnop/machinery/v1/config" "github.com/RichardKnop/machinery/v1/log" "github.com/RichardKnop/machinery/v1/tasks" "machineryDemo/controller" ) var configPath = "./machinery_config.yml" func loadConfig() (*config.Config, error) { ...
package cpu import ( "encoding/binary" "fmt" "log" "github.com/alexflk/nes/mem" ) type CPU struct { table [256]Instruction mem.MemoryInterface cpuState } type cpuState struct { pc uint16 // program counter sp byte // stack pointer a byte // accumulator x byte // index register x ...
// Copyright 2021 The Moov Authors // Use of this source code is governed by an Apache License // license that can be found in the LICENSE file. package document import ( "encoding/json" "encoding/xml" "github.com/moov-io/iso20022/pkg/utils" "io/ioutil" "path/filepath" "strings" "testing" "github.com/stretch...
package problem0114 // TreeNode is a struct type TreeNode struct { Val int Left *TreeNode Right *TreeNode } func flatten(root *TreeNode) { if root == nil { return } if root.Left != nil && (root.Left.Left != nil || root.Left.Right != nil) { flatten(root.Left) } if root.Right != nil && (root.Right.Left...
package innerSortImpl /** * @author liujun * @version 1.0 * @date 2021-06-20 13:09 * @author—Email liujunfirst@outlook.com * @blogURL https://blog.csdn.net/ljfirst * @description 插入排序 */ type InsertSort struct { } func (s *InsertSort) SortMethod(array []int) []int { if array == nil || len(array) <= 1 { re...
package spanner import ( "cloud.google.com/go/spanner" "context" "fmt" "github.com/chidakiyo/benkyo/spanner/models" "github.com/google/uuid" "github.com/greymd/ojichat/generator" "log" "sync" "testing" "time" ) func Test_Yoしてみる(t *testing.T) { ctx := context.Background() tx := con.ReadOnlyTransaction() d...
package requests import ( "encoding/json" "fmt" "io/ioutil" "net/url" "strings" "github.com/atomicjolt/canvasapi" "github.com/atomicjolt/canvasapi/models" ) // GetFeatureFlagCourses Get the feature flag that applies to a given Account, Course, or User. // The flag may be defined on the object, or it may be in...
// 活动服务 package elemeOpenApi // 创建减配送费活动 // createInfo 创建减配送费活动的结构体 // shopId 店铺Id func (shippingfee *Shippingfee) CreateShippingFeeActivity(createInfo_ interface{}, shopId_ int64) (interface{}, error) { params := make(map[string]interface{}) params["createInfo"] = createInfo_ params["shopId"] = shopId_ return AP...
// Copyright (C) 2017 Google 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 t...
// Copyright 2022 Google 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 ...
package backup import ( "testing" "time" "os" . "github.com/bborbe/assert" backup_host "github.com/bborbe/backup/host" backup_rootdir "github.com/bborbe/backup/rootdir" backup_testutil "github.com/bborbe/backup/testutil" "github.com/golang/glog" ) func TestMain(m *testing.M) { exit := m.Run() glog.Flush()...
package udwIpPacket import ( "github.com/tachyon-protocol/udw/udwNet/udwDns/udwDnsPacket" ) func TcpRstSameWay(ipPacket IpPacket, tmpBuf []byte) IpPacket { ipLen := ipPacket.GetIpHeaderLen() srcPortBuf := ipPacket.buf[ipLen+0 : ipLen+2] dstPortBuf := ipPacket.buf[ipLen+2 : ipLen+4] reqTcpSeqNumberBuf := ipPacket...
package pkg import "github.com/irfansharif/log" func Log(logger *log.Logger) { logger.Info("from pkg!") }
package model import ( "fmt" "github.com/gin-gonic/gin" _ "github.com/go-sql-driver/mysql" "github.com/jinzhu/gorm" "golang.org/x/crypto/bcrypt" "rain/library/go-str" "rain/library/helper" "strings" ) type Auth struct { } func (m *Auth) Login(ctx *gin.Context) (user Admin, status bool) { db := helper.Db() ...
package main type Orientation int const ( Vertical Orientation = 1 Horizontal Orientation = 2 LeftTurn Orientation = 3 // при движении по вертикали RightTurn Orientation = 4 // при движении по вертикали Intersection Orientation = 7 ) type Direction int const ( Up Direction = 0 Left Direction...
package portal import ( "github.com/Cepave/fe/http/base" "github.com/Cepave/fe/model/event" ) type PortalController struct { base.BaseController } func (this *PortalController) EventGet() { baseResp := this.BasicRespGen() _, err := this.SessionCheck() if err != nil { this.ResposeError(baseResp, err.Error()) ...
package changelog import ( "log" "os/exec" ) func gitAddAll() error { log.Printf("Executing `git add *`") c := exec.Command("git", "add", "*") return c.Run() } func gitStash() error { log.Printf("Executing `git stash`") c := exec.Command("git", "stash") return c.Run() } func gitStashPop() error { log.Print...
package hrtree import ( "fmt" h "github.com/jtejido/hilbert" "testing" ) var hf, _ = h.New(uint32(5), 2) func (r *rectangle) LowerLeft() Point { return r.lowerLeft } func (r *rectangle) UpperRight() Point { return r.upperRight } func rect(lower, upper Point) *rectangle { r, err := newRect(lower, upper) if ...
package mongodb import ( "time" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "golang.org/x/net/context" ) // Setting 配置 type Setting struct { ID primitive.ObjectID `bson:"_id,omitempty" json:"id"` Name string `bson:"name" json:"name"` // 名称 Description string `bson:"descr...
package main import ( "fmt" "os" "os/exec" "runtime" "strconv" "strings" "unsafe" "github.com/yamnikov-oleg/go-gtk/gdk" "github.com/yamnikov-oleg/go-gtk/gio" "github.com/yamnikov-oleg/go-gtk/glib" "github.com/yamnikov-oleg/go-gtk/gtk" "github.com/yamnikov-oleg/go-gtk/pango" ) var Ui struct { Window ...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package terraform import ( "fmt" "os" "os/exec" "strings" "github.com/mattermost/mattermost-cloud/internal/tools/exechelper" log "github.com/sirupsen/logrus" ) func arg(key string, values ...stri...
package main import ( "context" "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/log" "myRPC/demo/trace/base" "time" ) func main() { tracer, closer := base.Init("serName") defer closer.Close() opentracing.SetGlobalTracer(tracer) span := tracer.StartSpan("spanName") span.SetTag(...
package main import ( "fmt" "strings" ) func main() { hello := "Hello Builder" sb := strings.Builder{} sb.WriteString("<p>") sb.WriteString(hello) sb.WriteString("</p>") fmt.Println(sb.String()) words := []string{"Hello", "world"} sb.Reset() sb.WriteString("<ul>") for _, v := range words { sb.WriteSt...
//+build wireinject package server_tools import ( "context" "net/http" "github.com/google/wire" "github.com/YaroslavChirko/architecture-lab2/server/dbs" "database/sql" "github.com/YaroslavChirko/architecture-lab2/server/mhttp" ) type APIServer struct { db *sql.DB serv *http.Server } fu...
/* Copyright 2023 Gravitational, 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 in writing, soft...
package main import ( "bufio" "fmt" "os" "strings" ) func main() { welcome := ` ==================================================== TOP SECRET Super HAxx0r DATABASE WELCOME ANON 47 ENTER YOUR PASSWORD TO CONTINUE ==================================================== ` password := "5up32_53cu23_...
package job import ( "fmt" "reflect" "runtime" "testing" "time" "github.com/stretchr/testify/assert" ) func TestBacktrace(t *testing.T) { type args struct { size int } _, filename, _, _ := runtime.Caller(0) _, testingFile, _, _ := runtime.Caller(1) _, asmFile, _, _ := runtime.Caller(2) trace1 := fmt.S...
package frame256x288 import ( "github.com/reiver/go-rgba32" "image" "image/color" "image/draw" ) type Slice []uint8 func (receiver Slice) at(x, y int) []uint8 { if nil == receiver { return nil } if x < 0 || Width <= x { return nil } if y < 0 || Height <= y { return nil } offset := receiver.PixOffs...
// Copyright 2019 - 2022 The Samply Community // // 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 ...
package editorapi import ( "editorApi/controller/servers" "editorApi/init/mgdb" "strings" "time" "github.com/gin-gonic/gin" "github.com/tealeg/xlsx" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" ) var tblImageSys string = "image_sys" var tblImageSysTags string = "image_sys_t...
package handle import ( . "base" ) type C12002Down struct { SID string //String,掉线玩家的SID } func (s *C12002Down) PackInTo(p *Pack) { p.WriteUInt16(12002) //写入协议号 p.WriteString(s.SID) //掉线玩家的SID } func (s *C12002Down) ToBytes() []byte { pack := NewPackEmpty() s.PackInTo(pack) return pack.Data() }
package props import "os" var ( Port, ApiKey, Secret string ) func Setup() { ApiKey = os.Getenv("API_KEY_CONVERTER") Port = os.Getenv("PORT") Secret = os.Getenv("SECRET") }
/* * @lc app=leetcode id=542 lang=golang * * [542] 01 Matrix * * https://leetcode.com/problems/01-matrix/description/ * * algorithms * Medium (39.36%) * Likes: 1486 * Dislikes: 107 * Total Accepted: 87.7K * Total Submissions: 220.9K * Testcase Example: '[[0,0,0],[0,1,0],[0,0,0]]' * * Given a matri...
package block import ( "encoding/json" "github.com/transmutate-io/cryptocore/types" ) var ( _ Block = (*BlockDCR)(nil) _ TransactionsLister = (*BlockDCR)(nil) _ ConfirmationCounter = (*BlockDCR)(nil) _ ForwardBlockNavigator = (*BlockDCR)(nil) _ BackwardBlockNavigator = (*BlockDCR)(nil...
// // Sa labs // // API Docs for sa labs // Schemes: http // Version: 0.0.1 // Contact: Andriy Tymkiv <a.tymkiv99@gmail.com> // Host: localhost // // Consumes: // - application/json // // Produces: // - application/json // // // swagger:meta package main import ( "flag" gormsqlS "git...
package common import ( "bytes" "crypto/rand" "crypto/rsa" "crypto/x509" "encoding/json" "encoding/pem" "fmt" "github.com/bitly/go-simplejson" "strconv" "strings" "time" ) func StrFirstToUpper(str string) string { if len(str) < 1 { return "" } strArry := []rune(str) if strArry[0] >= 97 && strArry[0...
package rds import ( "testing" "github.com/pmacik/k8s-rds/pkg/crd" "github.com/stretchr/testify/assert" ) func TestConvertSpecToInput(t *testing.T) { db := &crd.Database{ Spec: crd.DatabaseSpec{ DBName: "mydb", Engine: "postgres", Username: "myuser", Class: ...
package main import ( "time" ) type Trend struct { Term string `json:"term"` SourceURI string `json:"source_uri"` Mined time.Time `json:"mined"` Posted time.Time `json:"posted"` WordCounts []WordCount `json:"word_counts"` } type Trends []Trend
package main import ( "context" "encoding/json" "flag" "fmt" "github.com/dherbst/sentry-web-api" ) var funcMap map[string]func(context.Context) func init() { funcMap = map[string]func(context.Context){ "help": Usage, "version": Version, "orgs": Organizations, "projects": Projects, "events":...
package logger import ( "context" "io" "log" ) type Logger struct { Trace *log.Logger Info *log.Logger Warning *log.Logger Error *log.Logger } func New(_ context.Context, traceHandle, infoHandle, warningHandle, errorHandle io.Writer) *Logger { var Logger Logger Logger.Trace = log.New(traceHandle, "TR...
package main import ( "context" "github.com/Fish-pro/grpc-server/helper" "github.com/Fish-pro/grpc-server/services" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "google.golang.org/grpc" "log" "net/http" "os" ) func main() { gwmux := runtime.NewServeMux() gRpcEndPoint := "localhost:8081" opt := []grp...
// GENERATED FILE -- DO NOT EDIT // package metadata var ( // Default is the name of snapshot default Default = "default" // LocalAnalysis is the name of snapshot localAnalysis LocalAnalysis = "localAnalysis" // SyntheticServiceEntry is the name of snapshot syntheticServiceEntry SyntheticServiceEntry = "synt...
// Copyright 2014 Dirk Jablonowski. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // The head object has all methods to work with the header of a packet. package head import ( "encoding/binary" "fmt" "github.com/dirkjabl/bricker/net/err...
/*------------------------------------------------------------------------- * * io_test.go * test cgroup io metrics * * * Copyright (c) 2021, Alibaba Group Holding Limited * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * Y...
package main import ( "fmt" "log" "os" "time" "io/ioutil" "math/rand" "github.com/grossamos/jam0001/evaluator" "github.com/grossamos/jam0001/lexer" "github.com/grossamos/jam0001/parser" "github.com/grossamos/jam0001/shared" ) func help() { fmt.Println( `smile - an esoteric programming language made for...
package main import "fmt" /* 考点:defer 闭包 指针变量 */ type Person struct { age int } func main() { //p是一个指针变量 p := &Person{25} //此处的defer中p将当前age 25作为参数,缓存到栈中 defer fmt.Println(p.age) //此处将p的引用地址,age最终被重新赋值 defer func(p *Person) { fmt.Println(p.age) }(p) //闭包 最终引用的是外部变量 defer func() { fmt.Println(p.age...
// Copyright 2020 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package firmware import ( "context" "fmt" "path/filepath" "time" "chromiumos/tast/ctxutil" "chromiumos/tast/errors" "chromiumos/tast/remote/dutfs" "chromiumos/tast/...
package mailgun import ( "net/http" "github.com/gorilla/mux" ) func (ms *mockServer) addIPRoutes(r *mux.Router) { r.HandleFunc("/ips", ms.listIPS).Methods(http.MethodGet) r.HandleFunc("/ips/{ip}", ms.getIPAddress).Methods(http.MethodGet) func(r *mux.Router) { r.HandleFunc("", ms.listDomainIPS).Methods(http.Me...
// Rect package GridSearch import ( "strconv" ) type rect struct { Left, Top, Right, Bottom int32 } func NewRectBy4String(v []string) (*rect, bool) { tleft, err := strconv.Atoi(v[0]) if err != nil { return nil, false } ttop, err := strconv.Atoi(v[1]) if err != nil { return nil, false }...
package mysql import ( "context" "database/sql" "reflect" "sync" _ "github.com/go-sql-driver/mysql" "shared/utility/naming" ) // 复用TableStruct,key是Table.Name var ( tables = &sync.Map{} mutex sync.Mutex ) type Handler struct { db *sql.DB } func NewHandler(db *sql.DB) *Handler { // db, err := sql.Open("m...
package main import "github.com/sanderkvale/IS105/ICA03/Oppg2/fileinfo" func main() { fileinfo.FilInformasjon() }
package admin import ( "github.com/caos/logging" view_model "github.com/caos/zitadel/internal/view/model" "github.com/caos/zitadel/pkg/grpc/admin" "github.com/golang/protobuf/ptypes" ) func viewsFromModel(views []*view_model.View) []*admin.View { result := make([]*admin.View, len(views)) for i, view := range vi...
package radareutil import ( "bytes" "fmt" "net/http" "net/url" "os/exec" "path/filepath" "strconv" "sync" "time" ) const ( cmdSubPath = "/cmd" ) // Deprecated: Use 'NewCustomHttpServerApi()' instead. type HttpApiOptions struct { Timeout time.Duration DoNotTrimWhiteSpace bool } // Deprecated:...
package adservertargeting import ( "encoding/json" "net/url" "strings" "github.com/buger/jsonparser" "github.com/prebid/openrtb/v19/openrtb2" "github.com/prebid/prebid-server/openrtb_ext" ) type DataSource string const ( SourceBidRequest DataSource = "bidrequest" SourceStatic DataSource = "static" So...
/* ###################################################################### # Author: (zfly1207@126.com) # Created Time: 2018-11-14 12:50:43 # File Name: main.go # Description: ####################################################################### */ package main import ( "flag" "fmt" "os" "strings" "ant-coder/c...
// Unless explicitly stated otherwise all files in this repository are licensed // under the Apache License Version 2.0. // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. package controllers import ( "fmt" "time" v1 "k8s.io/apimachinery/pk...
// Copyright © 2016 Zhang Peihao <zhangpeihao@gmail.com> package main import "github.com/zhangpeihao/zim/cmd" func main() { cmd.Execute() }
package main import ( "fmt" "math/rand" "time" ) func main() { rand.Seed(time.Now().UnixNano()) var a = [5]int{} for i := 0; i < len(a); i++ { a[i] = rand.Intn(100) } fmt.Println(a) temp := 0 for i := 0; i < len(a)/2; i++ { temp = a[i] a[i] = a[len(a)-i-1] a[len(a)-i-1] = temp } fmt.Println(a) }
package fcgi type Header struct { Version byte Type byte RequestId uint16 ContentLength uint16 PaddingLength byte Reserved byte //ContentData []byte //PaddingData []byte }
package operations // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command import ( "fmt" "github.com/go-openapi/runtime" strfmt "github.com/go-openapi/strfmt" ) // ModifyConnectionReader is a Reader for the ModifyConnection structure....
// Package record implements functions for marshaling and unmarshaling individual Kafka records. package record import "github.com/mkocikowski/libkafka/varint" func Unmarshal(b []byte) (*Record, error) { // TODO: errors r := &Record{} var offset, n int r.Len, offset = varint.DecodeZigZag64(b) r.Attributes = int8(...
/* * @lc app=leetcode id=11 lang=golang * * [11] Container With Most Water * * https://leetcode.com/problems/container-with-most-water/description/ * * algorithms * Medium (50.24%) * Likes: 6372 * Dislikes: 595 * Total Accepted: 678.1K * Total Submissions: 1.3M * Testcase Example: '[1,8,6,2,5,4,8,3,...
package config import ( "fmt" "github.com/rs/zerolog/log" "github.com/spf13/viper" "os" "path/filepath" ) func InitViper(configLocation, filename, extension string) { CheckConfigFile(configLocation, filename+extension) // Set up viper config library viper.SetConfigName(filename) viper.AddConfigPath(configLoc...
// Package operator contains main implementation of Flatcar Linux Update Operator. package operator import ( "context" "fmt" "time" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/selection" "...
package bench import ( "bytes" "compress/gzip" "io/ioutil" "os" "testing" ) var codeJSON []byte var codeStruct = &codeResponse{} func codeInit() { f, err := os.Open("testdata/code.json.gz") if err != nil { panic(err) } defer f.Close() gz, err := gzip.NewReader(f) if err != nil { panic(err) } data, e...
// Copyright 2019 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package main import "fmt" func main() { var a1 int var p1 *int p1 = &a1 *p1 = 1000 fmt.Println(a1) x1 := 123 x2 := 123 hoge(x1, &x2) fmt.Println(x1, x2) } // b1は値渡し b2はポインタ渡し func hoge(b1 int, b2 *int) { b1 = 456 *b2 = 456 }
// SPDX-FileCopyrightText: 2019 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol // TraceValue represents a InitializeParams Trace mode. type TraceValue string // list of TraceValue. const ( // TraceOff disable tracing. TraceOff TraceValue = "off" // TraceMessage normal tr...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package conference // RoomType defines room size for conference CUJ. type RoomType int const ( // NoRoom means not joining google meet when running the test. NoRoom RoomT...
package main; import "fmt"; p := make([]int, 1000001); seen := make(bool, 1000001); func find_set(x int) int { return (p[x] == x)? x : p[x] = find_set(p[x]); } func union_set(x int, y int) { px := find_set(x); py := find_set(y); if px != py { p[px] = py; } } func init(n int) { for i := 0; i <= n; i...
/* Command genblog generates a static blog. Create an article: genblog article <article-url-slug> Run a local server: genblog serve Build static HTML to `public/`: genblog build */ package main import ( "fmt" "os" ) func main() { if len(os.Args) < 2 { usage() } blog := currentBlog() switch os.Ar...
package tree import ( "errors" "log" ) // k 树的性质 // 节点数 n = n0 + n1 + n2 + ... + nk(nk 是具有k个子节点的节点数) // n = n1 + 2n2 +3n3 + ... + knk // 所以 n0 = n2 + 2n3 + ... + (k-1)nk // TNode 树根,树根是没有向上的 type TNode interface { SetVal(val interface{}) GetVal() interface{} Tree } // Tree 子树 type Tree interface { AddChild(TN...
// Copyright (C) 2017 Google 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 t...
package challenge_3 import ( "cryptopals/set_1/challenge_1" "unicode/utf8" ) func BuildCorpus(text string) map[rune]float64 { corpus := make(map[rune]float64) for _, c := range text { corpus[c] += 1 } total := utf8.RuneCountInString(text) for c := range corpus { corpus[c] /= float64(total) } return corp...
// Copyright 2018 The gVisor 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 agree...
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. // I am using the Golang driveR. Documentation can be found // at https://godoc.org/github.com/mattermost/platform/model#Client package main import ( "fmt" "os" "os/signal" "regexp" "strconv" "strings" "gi...
package gflObject import "github.com/garclak/gflgo/gflConst" type Runway struct { id : int Designation : string Surface : gflConst.SurfaceC Length : int LocFreq : float32 LocHeading : int LocAltFreq : float32 LocAltHeading : int Remarks : string } /* func (l *LogonC) Const(ref string) int { if ret, ok := l...
package storage_test // // Copyright (c) 2019 ARM Limited. // // SPDX-License-Identifier: MIT // // 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 witho...
// Copyright 2022 Gravitational, 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 agree...