text
stringlengths
11
4.05M
package main const esbuildVersion = "0.9.2"
package dynatrace import ( "github.com/keptn-contrib/dynatrace-service/internal/test" "testing" "time" ) func TestExecuteGetDynatraceSLO(t *testing.T) { handler := test.NewFileBasedURLHandler() handler.AddStartsWith("/api/v2/slo", "./testdata/test_get_slo_id.json") dtClient, _, teardown := createDynatraceClien...
// Copyright 2021 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package hwsec import ( "context" "google.golang.org/grpc" apb "chromiumos/system_api/attestation_proto" "chromiumos/tast/errors" "chromiumos/tast/local/hwsec" hwsecp...
package dsl import ( "github.com/onsi/ginkgo" "github.com/onsi/gomega" v1 "github.com/rancher/wrangler/pkg/generated/controllers/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func MustPVCDeleted(controller v1.PersistentVolumeClaimController, namespace, na...
import "fmt" /* * @lc app=leetcode id=401 lang=golang * * [401] Binary Watch * * https://leetcode.com/problems/binary-watch/description/ * * algorithms * Easy (47.18%) * Likes: 582 * Dislikes: 995 * Total Accepted: 84.3K * Total Submissions: 177.3K * Testcase Example: '0' * * A binary watch has 4...
package task func Task01(i interface{}) (interface{}, error) { config, ok := i.(Config) if !ok { return nil, typeError } attr01 := config.Attr01() attr02 := config.Attr02() attr01["I am map"] = 1 attr02 += 1 // 传递的数据需用map存储, 否则修改无效 return config, nil }
package patterns // Iterator is the interface for Java-style iterators. type Iterator interface { HasNext() bool Next() interface{} } // GetAll returns all the values that the Iterator i // (still) has. func GetAll(i Iterator) []interface{} { var result []interface{} for i.HasNext() { result = appe...
package auth import ( "net/http" "time" "github.com/jsm/gode/api/application" "github.com/jsm/gode/api/v1/requests" "github.com/jsm/gode/models" "github.com/jsm/gode/services" ) func testHandler(w http.ResponseWriter, r *http.Request) { authorizations, success := Authenticate(w, r) if !success { return } ...
package main import ( "fmt" "github.com/pocke/gha" ) func main() { key, err := gha.CLI("test-key", &gha.Request{ Note: "test app for gha", }) if err != nil { panic(err) } fmt.Println(key) }
package main type redis_set_req struct { Key string Value map[string]interface {} } type redis_get_req struct { Key string } type redis_resp struct { Key string Value map[string]string }
package monngo import "github.com/go-bongo/bongo" type Mongo interface { Connection(config bongo.Config) *bongo.Connection }
// Copyright 2019 The OctoSQL Authors. // Copyright 2020 The VectorSQL Authors. // // Code is licensed under Apache License, Version 2.0. package expressions import ( "fmt" "base/docs" "base/errors" "datavalues" ) type IValidator interface { docs.Documented Validate(args ...datavalues.IDataValue) error } typ...
package provider import ( "errors" "fmt" "github.com/evcc-io/evcc/provider/sma" "github.com/evcc-io/evcc/util" "gitlab.com/bboehmke/sunny" ) // SMA provider type SMA struct { device *sma.Device value sunny.ValueID scale float64 } func init() { registry.Add("sma", NewSMAFromConfig) } // NewSMAFromConfig ...
package user import ( // "img_tag/middleware" "github.com/gin-gonic/gin" ) func InitRouter(r *gin.Engine) { userRouter := r.Group("user").Use() { userRouter.GET("/error", GetUserError) userRouter.GET("/id", GetUser) } }
/* Copyright 2021 The Tekton 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, softw...
package main import fmt "fmt" // integer array for representating graph type graph [][]int // data structure queue with basic properties type queue []int func (q* queue) push(e int) { *q=(*q)[0:len(*q)+1] (*q)[len(*q)-1]=e } func (q* queue) pop() int { ret:=(*q)[0] *q=(*q)[1:] return ret } func cr...
package main import ( "context" "encoding/json" "fmt" "os" "path/filepath" "time" "github.com/ledisdb/ledisdb/ledis" "github.com/mylxsw/adanos-alert/agent/api" "github.com/mylxsw/adanos-alert/agent/config" "github.com/mylxsw/adanos-alert/agent/job" "github.com/mylxsw/adanos-alert/agent/store" "github.com/...
package jira import ( "context" "fmt" "io/ioutil" "net/http" "net/url" "github.com/andygrunwald/go-jira" ) // Issue 一个 Jira Issue type Issue struct { CustomFields map[string]interface{} `json:"custom_fields"` ProjectKey string `json:"project_key"` Summary string `json:...
package sics type Skin struct { Batsmen [2]string Overs []Over }
package main import ( . "imageserver/models" . "imageserver/service" "github.com/emicklei/go-restful" "net/http" "log" "github.com/bmizerany/pat" "fmt" ) func main() { app := App{Model:&TransformFactory{Session:&SessionDb{}},Neural:&LearningNeural{},MiniNeural:&LearningNeuralMini{},Training:&Training{}} app...
package aws import ( "fmt" "net/http" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" ) const ( HttpClientTimeout = 30 ) func getSession(region string) (ss *session.Session, err error) { // TODO Use getSession for ec2 service too cr...
package gobucket import ( "encoding/json" ) func GetHookData(payload []byte) (*Hook, error) { var h Hook err := json.Unmarshal(payload, &h) if err != nil { return nil, err } return &h, nil } type Hook struct { Repository HookRepository `json:"repository"` Truncated bool `json:"truncated"` C...
package store import ( "github.com/SamuelRamond/xauth/model" ) // Store is an Interface you need to satisfy to implement your own backend type Store interface { AddPermission(p *model.Permission) error UpdatePermissions(userID uint64, pss []*model.Permission) error GetPermissions(userID uint64) []*model.Permissio...
package call import ( "crypto/md5" "encoding/json" "fmt" M "github.com/ionous/sashimi/compiler/model" G "github.com/ionous/sashimi/game" "github.com/ionous/sashimi/util/ident" "io" "reflect" "runtime" "strings" ) type Marker struct { M.CallbackModel } func MarkFileLine(file string, line int) Marker { ret...
package main import "strings" type matcher interface { Match(string) bool } type globMatcher struct { parts []string caseSensitive bool anyMatch bool exactMatch bool leadingGlob bool trailingGlob bool } func newGlob(pattern string) *globMatcher { m := new(globMatcher) if pattern == "*" {...
package main import ( "fmt" "os" ) func main() { mapper, err := NewJIS0213RuneMapper() if err != nil { fmt.Fprintf(os.Stderr, "sjis to unicode mapping construction failed: %v", err) os.Exit(1) } for k, v := range *mapper { if len(v) > 1 { fmt.Printf("%#0X(%d): %c\n", k, k, k) for _, vv := range v { ...
package system import ( "go-xops/dto/cacheService" "go-xops/dto/request" "go-xops/dto/response" "go-xops/dto/service" "go-xops/models/system" "go-xops/pkg/utils" "strconv" "time" "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" ) // 获取操作日志列表 func GetOperLogs(c *gin.Context) { // 绑定参数 var req reque...
/* Copyright 2017 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, ...
// 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 a Formatter }
package api import ( "encoding/json" "fmt" "net/http" "net/url" "strconv" "strings" "sync" "gorm.io/gorm" semver "github.com/Masterminds/semver/v3" "github.com/porter-dev/porter/internal/analytics" "github.com/porter-dev/porter/internal/kubernetes/prometheus" "github.com/porter-dev/porter/internal/models...
// Package ecdsa implements the Elliptic Curve Digital Signature Algorithm, as // defined in https://en.bitcoin.it/wiki/Elliptic_Curve_Digital_Signature_Algorithm package ecdsa import ( "bytes" "crypto/hmac" "crypto/sha256" "errors" "io" "math/big" "github.com/VIVelev/btcd/crypto/elliptic" "github.com/VIVelev...
package main import ( "context" "errors" "fmt" "time" "github.com/AlexanderEkdahl/rope/version" ) // TODO: Add update parameter for when to use the latest version of transitive // dependency. func add(timeout time.Duration, packages []string) error { ctx := context.Background() if timeout > 0 { var cancel c...
// Copyright © 2019 Maks Balashov <maksbalashov@gmail.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 required by ap...
package middlewares import ( "project/config" "github.com/labstack/echo" "github.com/labstack/echo/middleware" ) // Leverage default authentication middleware from echo func AuthenticationMiddleware() echo.MiddlewareFunc { return middleware.JWTWithConfig(middleware.JWTConfig{ SigningMethod: "HS256", SigningK...
// Copyright 2019 Yunion // // 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 writi...
package limiter import ( "context" "errors" ) var ErrLimited = errors.New("limiter: Limited") type DoneFunc func() type AllowOptions struct { NoWait bool N int } type Limiter interface { Allow(context.Context, AllowOptions) (DoneFunc, error) }
package main import ( "errors" "fmt" "log" "net/http" "github.com/cyc-ttn/gorouter" . "github.com/altrudos/api" ) var ( ErrBlankConfigPath = errors.New("config file path is blank") ErrNoPort = errors.New("port in config is empty") ) type Server struct { S *Services Config *Config R *g...
package actions import "log" import "cointhink/proto" import gproto "github.com/golang/protobuf/proto" import "cointhink/model/algorithm" func DoAlgorithmList(_algorithmList *proto.AlgorithmList, accountId string) []gproto.Message { var responses []gproto.Message rows, err := algorithm.FindReady() if err != nil {...
package array // Permutations test // Given a collection of numbers, return all possible permutations func Permutations(arr []int, start int) [][]int { temp := make([]int, 0) temp = append(temp, arr[start:]...) res := make([][]int, 0) if len(temp) == 2 { res = append(res, []int{temp[0], temp[1]}) res = append...
package constants const ( // DBConnectionString : mysql connection string DBConnectionString string = "root:password@/gatorloop?charset=utf8" // TotalPodDistance : the total distance from start to finish of the track TotalPodDistance float64 = 5000 )
package service import ( "errors" "testing" "github.com/scottski/di-test/pkg/database" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) func Test_ReceiveMessage_Success(t *testing.T) { dbMock := &database.DBMock{} // Return this on any argument passed in dbMock.On("Upsert", mock.An...
/* * Copyright 2020 The Dragonfly 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 la...
// This file has been created by "go generate" as initial code. go generate will never update it, EXCEPT if you remove it. // So, update it for your need. package main import ( "io/ioutil" "fmt" "github.com/forj-oss/goforjj" "github.com/xanzy/go-gitlab" "gopkg.in/yaml.v2" ) //GitlabPlugin main struct type Git...
package audioprocessing import ( "github.com/xfrr/goffmpeg/transcoder" "log" ) type FFmpegPlayer struct { PlayerNo int Trans *transcoder.Transcoder Tracks TrackManager } func (fp *FFmpegPlayer) Queue(t Track) int { index := fp.Tracks.AddTrack(t) log.Printf("[ Player %v ] Queued track at position %v", fp....
package main import ( "log" "net/http" "strings" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" ) const gitRevision = "<filled in by CI service>" func main() { // start collector coll := NewCollector(conf.db, conf.ms, conf.scanInterval, conf.extraServers, conf.verbose) go coll.Run() // start w...
package simplegrab import ( "crypto/md5" "encoding/hex" "errors" "io" "net/http" "os" "strings" "github.com/PuerkitoBio/goquery" ) // 计算string的md5值,以32位字符串形式返回 func StringToMd5(s string) string { h := md5.New() io.WriteString(h, s) return hex.EncodeToString(h.Sum(nil)) } // 将数据(url)下载到本地(filepath) // 注意:...
package server import ( "encoding/json" "fmt" "log" "net/http" "github.com/dan-v/seattlerb-battleship/battleship" "github.com/dan-v/seattlerb-battleship/common" ) type Server struct { wins int losses int gameID int games map[int]*battleship.Game previousGuess map[int]battles...
package entitys import ( "time" ) type ArticleBox struct { ID string `gorm:"type:uuid; primary_key; default: uuid_generate_v4();" json:"id"` Name string `gorm:"size:100" json:"name"` Creator User CreatorId string `gorm:"type:varchar(100)" json:"-"` Type string `gorm:"size:30;default:'...
package im import ( "encoding/json" "errors" ) const userBaseUrl = "https://api.im.jpush.cn/v1/users/" type User struct { IM } type UserInfo struct { UserName string `json:"username"` AppKey string `json:"appkey"` //用户所在的appkey 估计android ios不能使同一个应用 Password string `json:"password"` //极光会md5一次 NickNa...
package thttp import ( "errors" "fmt" "io/ioutil" "net/http" "net/http/httptest" "net/url" "strings" "testing" "github.com/google/uuid" "github.com/jrapoport/gothic/config" "github.com/jrapoport/gothic/jwt" "github.com/jrapoport/gothic/models/user" "github.com/stretchr/testify/require" ) // Do does an h...
package main import "sort" //1365. 有多少小于当前数字的数字 //给你一个数组nums,对于其中每个元素nums[i],请你统计数组中比它小的所有数字的数目。 // //换而言之,对于每个nums[i]你必须计算出有效的j的数量,其中 j 满足j != i 且 nums[j] < nums[i]。 func smallerNumbersThanCurrent(nums []int) []int { dic := make(map[int][]int) for i, v := range nums { dic[v] = append(dic[v], i) } sort.Ints(nu...
package main func minSubArrayLen(s int, nums []int) int { array := make([]int, 0) result := 0 sum := 0 for _, w := range nums { array = append(array, w) sum += w for sum >= s { if result == 0 || result > len(array) { result = len(array) } sum -= array[0] array = array[1:] } } return res...
package controllers import ( "github.com/1046102779/common/consts" . "github.com/1046102779/official_account/logger" "github.com/1046102779/official_account/models" "github.com/astaxie/beego" "github.com/pkg/errors" ) // IndustryCodeQuerysController oprations for IndustryCodeQuerys type IndustryCodeQuerysControl...
package core import "math" /* Sigmoid implements methods for the vectorized sigmoid function, s(x_i) = 1 / (1 + exp(-x_i)) */ type Sigmoid struct{} func (a Sigmoid) Name() string { return "Sigmoid" } func (a Sigmoid) Eval(x, Fx []float32) { for i, u := range x { Fx[i] = float32(1.0 / (1.0 + math.Exp(-float6...
package string import ( "fmt" "github.com/project-flogo/core/data/coerce" "strings" "github.com/project-flogo/core/data" "github.com/project-flogo/core/data/expression/function" ) func init() { function.Register(&fnTrim{}) } type fnTrim struct { } func (fnTrim) Name() string { return "trim" } func (fnTrim)...
// Package users provides a domain model for working with users package users import ( "encoding/json" "fmt" "io/ioutil" "net/http" "github.com/gin-gonic/gin" "github.com/jceatwell/bookstore_users-api/domain/users" "github.com/jceatwell/bookstore_users-api/services" ) //CreateUser creates new user func Create...
package discovery import ( "errors" "github.com/patrickmn/go-cache" "github.com/prometheus/common/log" LOG "github.com/sirupsen/logrus" "github.com/thinker0/go-serversets" "regexp" "strings" "time" ) type ( ServiceSetsCache struct { hosts []string pathServerSet *cache.Cache pathWatcher *cache.Ca...
package main // TODO: go-doc import ( "log" "net" "net/http" "net/rpc" "os" "github.com/frncmx/screener-prezi/backend/prezidb" ) const portEnvKey = "PREZI_BACKEND_PORT" // Listener is a global, initialized before main(). That makes random port // number accessible from tests. // TODO: Think and ask for opini...
package main import "fmt" type pc struct { ram int disk int brand string } func (compt *pc) duplicateRAM() { compt.ram = compt.ram * 2 } func (compt pc) ping() { fmt.Println(compt.brand, "Pong") } func main() { a := 50 b := &a fmt.Println(a, b) fmt.Println(a, *b) myPC := pc{ram: 16, disk: 1024, bran...
// 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 models import ( "strconv" "../utils" ) func GetKey() int64 { var key int64 var val string // 获取 key err := db.QueryRow("SELECT `val` FROM `setting` WHERE `key` = 'key' LIMIT 1").Scan(&val) utils.CheckErr(err) key, err = strconv.ParseInt(val, 10, 64) utils.CheckErr(err) ...
// Copyright 2018 Authors of Cilium // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed ...
package server import ( "encoding/json" "fmt" "log" "net/http" "github.com/gorilla/mux" "github.com/ivan-kapelyukh/knock-knock-unlock/internal/app/server/mongo" ) type Server struct { port int staticDir string mongo *mongo.Mongo } func New(port int, staticDir string, mongo *mongo.Mongo) Server { ...
package packet import ( "bytes" "testing" ) func noop() {} type TestPacket struct { id uint field uint8 } func (tp *TestPacket) MarshalBinary() []byte { return []byte{byte(tp.id), byte(tp.field)} } func (tp *TestPacket) UnmarshalBinary(data []byte) error { return nil } func (tp *TestPacket) setHeader(h *H...
/* Copyright (c) 2019 The Helm 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, sof...
package bot import ( "context" "encoding/json" "fmt" "net/http" "net/url" "regexp" "strconv" "strings" "github.com/bots-house/share-file-bot/pkg/log" "github.com/bots-house/share-file-bot/pkg/tg" "github.com/bots-house/share-file-bot/service" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" "gi...
package perf import ( "encoding/json" "fmt" "io/ioutil" "net/http" "time" "github.com/ghodss/yaml" "github.com/gofrs/uuid" "github.com/layer5io/meshery/mesheryctl/internal/cli/root/config" "github.com/layer5io/meshery/mesheryctl/internal/cli/root/constants" "github.com/layer5io/meshery/mesheryctl/pkg/utils"...
package client import ( "encoding/json" "net" ) const ( EOL = "\n" ) type Client interface { Connect() error Disconnect() error Authorizate() error TankCommand(message Message) error SendMessage(message Message) error ReadMessage() (Message, error) ReadType(string) (Message, error) ReadWorld() (Message,...
// This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT License was not distributed with this // file, you can obtain one at https://opensource.org/licenses/MIT. // // Copyright (c) DUSK NETWORK. All rights reserved. package consensus import ( "bytes" "errors" "time" "github....
package version import ( "fmt" "runtime" ) // The current version of remote-structure-test // This is a private field and is set through a compilation flag from the Makefile var version = "v0.0.0-unset" var buildDate string var platform = fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH) type Info struct { Ver...
package main import "fmt" func main() { fmt.Println(myPow(244, 3243)) } func Pow(x float64, n int) float64 { return myPow(x, n) } func myPow(x float64, n int) float64 { if n == 0 { return 1 } if n%2 == 0 { return myPow(x*x, n>>1) } else { return myPow(x, n-1) * x } }
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package provisioner import ( "context" "fmt" "strings" "time" "github.com/mattermost/mattermost-cloud/k8s" "github.com/mattermost/mattermost-cloud/model" "github.com/mattermost/mattermost-operato...
package main import ( "fmt" "github.com/Snaxai/IS105/ICA02/Oppg3/unicode" ) func main() { unicode.SkrivUT() fmt.Println() unicode.SkrivUTx() fmt.Println() unicode.Printunicode() fmt.Println() unicode.SkrivUTotherunicode() }
package Next_Permutation import ( "testing" "github.com/stretchr/testify/assert" ) func TestNextPermutation(t *testing.T) { ast := assert.New(t) case0 := []int{1, 1} nextPermutation(case0) ast.Equal([]int{1, 1}, case0) case1 := []int{1, 2, 3} nextPermutation(case1) ast.Equal([]int{1, 3, 2}, case1) case2...
package main import ( "sort" "strconv" "strings" "github.com/innermond/pak" ) func boxesFromString(dimensions []string, extra float64) (boxes []*pak.Box) { for _, dd := range dimensions { d := strings.Split(dd, "x") if len(d) == 2 { d = append(d, "1", "1") // repeat 1 time } else if len(d) == 3 { d ...
package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" ) // http server func main(){ http.HandleFunc("/",f1) http.HandleFunc("/api",f2) http.ListenAndServe("127.0.0.1:9091",nil) // http.ListenAndServe("0.0.0.0:9091",nil) //上服务器时写 } func f2(w http.ResponseWriter,reve *http.Request){ ...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package model import ( "encoding/json" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) var nilHuv *HelmUtilityVersion // provides a typed nil; never initializ...
package main import ( "fmt" "net" "net/url" ) func main() { u := "http://admin:12345@localhost:8080/eureka?opt=add#k" uurl, err := url.Parse(u) defer func() { if err!=nil{ panic(err) } }() fmt.Printf("%p \n",uurl) fmt.Println(uurl) fmt.Println(*uurl) fmt.Println("-----------------------") fmt.Prin...
package goserver import ( "errors" "fmt" "log" "sync" "testing" "time" "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" pb "github.com/brotherlogic/discovery/proto" pbg "github.com/brotherlogic/goserver/proto" pbd "github.com/brotherlogic/monitor/proto" ) type basicGett...
/* * Copyright IBM Corporation 2021 * * 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 o...
package tally import ( "errors" "os" "path" ) func workspacePath() (string, error) { wsPath, ok := os.LookupEnv("HOME") if !ok { return wsPath, errors.New("$HOME is not set") } wsPath = path.Join(wsPath, ".config/tally") return wsPath, nil }
package main import "sort" // Leetcode 435. (medium) func eraseOverlapIntervals(intervals [][]int) int { if len(intervals) <= 1 { return 0 } sort.Slice(intervals, func(i, j int) bool { return intervals[i][1] < intervals[j][1] }) save := 1 right := intervals[0][1] for _, tmp := range intervals[1:] { if t...
// @author Couchbase <info@couchbase.com> // @copyright 2015 Couchbase, 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 // // Un...
// Copyright 2019 Liquidata, 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...
package main func main() { // For sum := 0 for i := 0; i < 6; i++ { if sum += i; sum < 5 { continue } println("for 1", i, sum) } println("for 2", sum) // For existing var i := 0 for i = 0; i < 6; i++ { println("for 3", i) } println("for 4", i) // For condition only i = 0 for i < 6 { i++ pri...
package main import ( "flag" "log" "github.com/engelsjk/faadb/rpc/reserved" "github.com/engelsjk/faadb/servers/reservedserver" "github.com/engelsjk/faadb/twirpserver" ) func main() { var flagPort = flag.String("p", "8084", "port") var flagDataPath = flag.String("d", "", "data path") var flagDBPath = flag.St...
package stdlib_test import ( "sync" "testing" "github.com/niolabs/gonio-framework" ) func put(t *testing.T, b nio.Block, terminal string, signals ...nio.Signal) { if err := b.Enqueue(nio.Terminal(terminal), signals); err != nil { t.Error(err) } } func takeOne(t *testing.T, b <-chan nio.SignalGroup, wg *sync....
package httputil import ( "net/url" "golang.org/x/text/encoding/simplifiedchinese" "golang.org/x/text/transform" ) func utf8ToGBK(utf8str string) string { result, _, _ := transform.String(simplifiedchinese.GBK.NewEncoder(), utf8str) return result } func gbkToUtf8(gbKstr []byte) []byte { result, _, _ := transf...
package hash var sha256K = []uint32{0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x7...
package main import ( "fmt" "runtime" "sync" "time" ) // creamos un waitgroup var wg sync.WaitGroup // esto le va a indicar el numero de hilos que va a usar el programa, // aqui esta puesto al maximo que soporta la cpu. Desde go 1.5 este es el // valor por defecto y por tanto no es necesario especificarlo, pero ...
// This file contains the types describing the map data. package rep import "github.com/icza/screp/rep/repcore" // MapData describes the map and objects on it. type MapData struct { // Version of the map. // 0x2f: StarCraft beta // 0x3b: 1.00-1.03 StarCraft and above ("hybrid") // 0x3f: 1.04 StarCraft and above ...
package ffmpeg /* #include <libavformat/avformat.h> #include <libavutil/opt.h> #include <libavutil/error.h> #include <libavutil/avstring.h> char errbuf[AV_ERROR_MAX_STRING_SIZE] = {0}; char *av_err(int errnum) { av_strerror(errnum, errbuf, AV_ERROR_MAX_STRING_SIZE); return errbuf; } */ import "C" import ( "fm...
//go:generate stringer -type=QRS package heartbeat // QRS is the event describing the activity of a heartbeat type QRS int const ( A QRS = iota V N F P X ) // validQRS contains only valid heartbeat QRS var validQRS = []QRS{A, V, N, F, P} func randomQRS() QRS { return validQRS[randomInt(0, len(validQRS)-1)] }...
package tui import "github.com/nsf/termbox-go" type sidebarScreen struct { cursor Point } func (scr *sidebarScreen) title() string { return "Menu" } func (scr *sidebarScreen) draw(lt Point, rb Point) { var i int var entry iScreen for i, entry = range availScreens { var title string = shrink(entry.title(), rb...
// 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 service import ( "context" proto "go-micro-demos/circuitbreaker/hystrixdo/proto/house" "strconv" "time" ) type HouseService struct { } func newHouse(id int32, name string, floor int32) *proto.RequestData { return &proto.RequestData{Name:name, Id:id, Floor:floor} } func (*HouseService) G...
// The entry point function is GenerateC // GenerateC setups the head and foot of the C program then // the function calls GenNode which recursively visits each node // of the parse tree generated by the parser. // Functions such as GenExpression or GenVariableDeclaration // are called depending on the visited node's p...
package cmd import ( "os" "os/signal" "github.com/7phs/coding-challenge-search/config" "github.com/7phs/coding-challenge-search/db" "github.com/7phs/coding-challenge-search/logger" "github.com/7phs/coding-challenge-search/model" "github.com/7phs/coding-challenge-search/nlp" "github.com/7phs/coding-challenge-s...
package Wiggle_Subsequence import ( "testing" "github.com/stretchr/testify/assert" ) func TestWiggle(t *testing.T) { ast := assert.New(t) ast.Equal(0,wiggleMaxLength([]int{})) ast.Equal(1, wiggleMaxLength([]int{0, 0})) ast.Equal(6, wiggleMaxLength([]int{1, 7, 4, 9, 2, 5})) ast.Equal(7, wiggleMaxLength([]int{...