text
stringlengths
11
4.05M
package array import ( "github.com/project-flogo/core/data" "github.com/project-flogo/core/data/expression/function" "github.com/project-flogo/core/support/log" ) type Create struct { } func init() { function.Register(&Create{}) } func (s *Create) Name() string { return "create" } func (s *Create) Sig() (para...
/* * @lc app=leetcode id=1480 lang=golang * * [1480] Running Sum of 1d Array * * https://leetcode.com/problems/running-sum-of-1d-array/description/ * * algorithms * Easy (93.64%) * Likes: 305 * Dislikes: 40 * Total Accepted: 70.2K * Total Submissions: 77.3K * Testcase Example: '[1,2,3,4]' * * Give...
package textMetrics import ( "github.com/RobertGumpert/vkr-pckg/runtimeinfo" "github.com/RobertGumpert/vkr-pckg/textPreprocessing" "github.com/RobertGumpert/vkr-pckg/textPreprocessing/textDictionary" "github.com/RobertGumpert/vkr-pckg/textPreprocessing/textVectorized" "testing" ) var ( testCorpus = []string{ ...
package main import ( "sort" ) // O(w * n * log(n) + n * w * log(w)) itme | O(wn) space // w = number of words, n = length of the longest word func GroupAnagrams(words []string) [][]string { if len(words) == 0 { return [][]string{} } sortedWords := []string{} indices := []int{} for i, word := range words { ...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package model import "github.com/pkg/errors" // PGBouncerConfig contains the configuration for the PGBouncer utility. // ////////////////////////////////////////////////////////////////////////////// //...
package command import ( "familyTree/src/data" "familyTree/src/family" "familyTree/src/person" "testing" "github.com/stretchr/testify/assert" ) var tree family.Tree func TestMain(m *testing.M) { tree = data.Build() m.Run() } func TestShouldReturnTheRelatedMembers(t *testing.T) { executeFunc := GetCommandFu...
package service import ( "net/url" "github.com/cerana/cerana/acomm" "github.com/cerana/cerana/pkg/errors" "github.com/cerana/cerana/providers/systemd" ) // RestartArgs are arguments for Restart. type RestartArgs struct { ID string `json:"id"` BundleID uint64 `json:"bundleID"` } // Restart restarts a ser...
package main import ( "encoding/json" "fmt" "os" ) type ColorGroup struct { ID int Name string Colors []string } type Car struct { Name string Manufacturer string } var jsonBlob = []byte(`[ {"Name": "WRX", "Manufacturer": "Subaru"}, {"Name": "BRZ", "Manufacturer": "Subaru/Toyota"}, {"Name":...
package logger import ( "github.com/I-Reven/Hexagonal/src/domain/entity" "github.com/I-Reven/Hexagonal/src/infrastructure/repository/redis/track" "github.com/gin-contrib/sessions" "github.com/gin-gonic/gin" ) var ( Session sessions.Session = nil ) type Tracker struct { track track.Track } func (t *Tracker) Cr...
package utils import ( "encoding/json" "net/http" ) type responseApi struct { Code int `json:"code"` Msg string `json:"msg"` Payload *interface{} `json:"payload,omitempty"` } func CreateResponseSuccess(w http.ResponseWriter, code int, pld interface{}) { data, _ := json.Marshal(&responseA...
package saml import "encoding/base64" import "encoding/xml" type SAMLRole struct { RoleArn string PrincipalArn string } type Response struct { XMLName xml.Name Assertion Assertion `xml:"Assertion"` } type Assertion struct { XMLName xml.Name AttributeStatement AttributeStatement } type Attri...
package models import ( "github.com/mobilemindtec/go-utils/beego/db" ) type Estado struct { Id int64 `form:"-" json:",string,omitempty"` Nome string `orm:"size(100)" valid:"Required;MaxSize(100)" form:""` Uf string `orm:"size(2)" valid:"Required;MaxSize(2)" form:""` Session *db.Session `orm:"-" json:"-" i...
package util import "testing" func TestLowerBound(t *testing.T) { tt := []struct { name string value int bound int expected int }{ { name: "zeros", value: 0, bound: 0, expected: 0, }, { name: "same", value: 5, bound: 5, expected: 5, }, { nam...
package pipa import ( "github.com/Shopify/sarama" "github.com/bsm/sarama-cluster" ) // Consumer interface type Consumer interface { Messages() <-chan *sarama.ConsumerMessage MarkOffset(*sarama.ConsumerMessage, string) Close() error } // NewConsumer connects to a real consumer func NewConsumer(addrs []string, gr...
// 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 transform import ( snapshot "github.com/pganalyze/collector/output/pganalyze_collector" "github.com/pganalyze/collector/state" ) func transformPostgresBackendCounts(s snapshot.FullSnapshot, transientState state.TransientState, roleOidToIdx OidToIdx, databaseOidToIdx OidToIdx) snapshot.FullSnapshot { for _,...
// Copyright 2018 Aleksandr Demakin. All rights reserved. package card // EventHeader is a common part for all events. type EventHeader struct { WebsiteURL string SessionID string } // Dimension is a width/height pair. type Dimension struct { Width, Height int } // Handler handles card-related events. type Hand...
// Copyright (c) 2018 Palantir Technologies. 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 require...
package server import ( "net/http/httptest" "testing" ) func TestNotFoundHandler_ServerHTTP(t *testing.T) { respRecorder := httptest.NewRecorder() notFoundHandler := &notFoundHandler{} notFoundHandler.ServeHTTP(respRecorder, nil) var expectedCode = 404 if respRecorder.Code != expectedCode { t.Errorf("Expec...
package user import ( //"net/http" //"webserver/common" "webserver/controllers" "webserver/lib/alioss" ) type OssStsTokenController struct { controllers.BaseController } func (c *OssStsTokenController) Get() { defer c.Recover() respBody, _ := c.getStsToken() c.WriteBodyResponse(respBody) } func (c *OssStsTo...
package protocol import ( "github.com/13k/go-steam-resources/steamlang" "github.com/13k/go-steam/steamid" ) // Message is the interface for all messages, typically outgoing. // // They can also be created by using the Read* methods of Packet. type Message interface { Serializer IsProto() bool Type() steamlang.E...
// Copyright (C) 2018 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 create import ( "encoding/json" "fmt" "net/http" "os" "github.com/ocoscope/face/db" "github.com/ocoscope/face/utils" "github.com/ocoscope/face/utils/answer" ) func InvitationUsers(w http.ResponseWriter, r *http.Request) { type tbody struct { UserID, DepartmentID, CompanyID uint AccessToken ...
package main import ( "encoding/hex" "flag" "fmt" "log" "net" "github.com/bnordbo/nff-go/flow" "github.com/bnordbo/nff-go/packet" "github.com/bnordbo/nff-go/types" ) var ( teid = flag.Int("teid", 1, "GTP-U TEID") srcIP = flag.String("src-ip", "", "Source IP address") dstIP = flag.String("dst-ip", "", ...
package cfg import ( "github.com/sirupsen/logrus" ) //singleton logger var Logger *logrus.Entry func init() { Logger = logrus.WithFields(logrus.Fields{}) } func NewLogger() { Logger = logrus.WithFields(logrus.Fields{}) } func BindFields(fields logrus.Fields) { Logger = Logger.WithFields(fields) }
// Solution to excericise : https://tour.golang.org/moretypes/23 package main import ( "strings" "golang.org/x/tour/wc" ) //WordCount returns count of occurance for each word in given string s func WordCount(s string) map[string]int { words := strings.Fields(s) wc := make(map[string]int) for i := range words { ...
package tiltfile import ( "bytes" "fmt" "os" "path/filepath" "sort" "strings" "github.com/docker/distribution/reference" "github.com/moby/buildkit/frontend/dockerfile/dockerignore" "github.com/pkg/errors" "go.starlark.net/starlark" "github.com/tilt-dev/tilt/internal/container" "github.com/tilt-dev/tilt/i...
package swproxy import ( "bytes" "encoding/base64" "errors" "io/ioutil" "net/http" "strings" grpczerolog "github.com/cheapRoc/grpc-zerolog" "github.com/elazarl/goproxy" "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/swarpf/proxy/pkg/events" "github.com/swarpf/proxy/pkg/utils" ) type Pro...
package service import ( "github.com/gin-gonic/gin" "net/http" "go-todo/util" "go-todo/database" "go-todo/model" ) // PostHandler ... func PostHandler(c *gin.Context) { db := database.Connect(c) defer db.Close() t := model.Todo{} err := c.ShouldBindJSON(&t) util.BadRequest(c, err) query := "INSERT INTO t...
package postgres import ( "database/sql" "errors" "log" "os" "time" "github.com/CafeLucuma/go-play/users/pkg/adding" "github.com/CafeLucuma/go-play/users/pkg/authentication" "github.com/CafeLucuma/go-play/utils/logging" _ "github.com/lib/pq" ) type Storage struct { db *sql.DB } // NewStorage returns a ne...
package main import ( "strings" ) type Filter interface { match(profile provisioningProfile) bool } type CompoundFilter struct { filters []Filter } func (receiver CompoundFilter) match(profile provisioningProfile) bool { for _, f := range receiver.filters { if !f.match(profile) { return false } } retu...
// Copyright 2015 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 (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 daemon import ( "github.com/alauda/kube-ovn/pkg/util" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/klog" "time" ) // InitNodeGateway init ovn0 func InitNodeGateway(config *Configuration) error { var portName, ipAddr, macAddr, gw string for { nodeName := config.NodeName node, err := config.KubeC...
package log import ( "bufio" "bytes" "fmt" "net" "os" "strings" "sync" "time" ) const ( defaultFlushSec = 30 writeByteSize = 2048 ) type Logger interface { Printf(format string, v ...interface{}) Infof(format string, v ...interface{}) Debugf(format string, v ...interface{}) Warnf(format string, v ......
package main import ( "fmt" "testing" ) func Test_run(t *testing.T) { type args struct { mt Mountains } tests := []struct { args args want string }{ { args{Mountains{ &Mount{"Everest", 8849}, &Mount{"K2", 8611}, &Mount{"Kangchenjunga", 8586}, }}, "K2", }, { args{Mountains{ ...
package main /* func main() { var a = 21 var b = 10 var c int c = a + b println(c) a-- println(a) } func main() { var a = 10 if a < 10 { print(a) } else { a++ print(a) } } func main() { var grade string = "B" var marks int = 70 switch marks { case 90: grade = "A" case 80,70: grade = "B" cas...
// utilgen holds various utility function primarily for documenting the algs output and performance // as well as some common generic-like functions package utilgen import ( "errors" "fmt" "time" "github.com/paulidealiste/goalgs/rangen" ) // Simple timetracker function called with defer at the onset of the funct...
package elevengo import "strconv" // Get file list under the specific category. // // "0" is a special categoryId which means the root, // everything starts from here. // // `offset` is base on zero. // // `limit` can not be lower than `FileListMinLimit`, // and can not be higher than `FileListMaxLimit` // // `sort`...
package imapmaildir import ( "errors" "fmt" "os" "path/filepath" "strings" "time" "github.com/asdine/storm/v3" "github.com/emersion/go-imap/backend" "github.com/emersion/go-maildir" "go.etcd.io/bbolt" ) const ( InboxName = "INBOX" HierarchySep = "." MaxMboxNesting = 100 IndexFile = "imapmaildir...
// Package kv abstracts a distributed/clustered kv store for use with cerana // kv does not aim to be a full-featured generic kv abstraction, but can be useful anyway. // Only implementors imported by users will be available at runtime. // See documentation of KV for handled operations. package kv import ( "net/url" ...
// SPDX-FileCopyrightText: Copyright 2019 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package jsonrpc2 import ( "errors" "fmt" "github.com/segmentio/encoding/json" ) // Error represents a JSON-RPC error. type Error struct { // Code a number indicating the error type that occurred. C...
package main import ( "strings" "testing" ) // http://stackoverflow.com/a/32081891/597260 func stripWhitespace(str string) string { return strings.Join(strings.Fields(str), "") } func TestRender(t *testing.T) { template := Template{ Name: "default", Data: map[string]string{ "body": "", "replyTo...
package lfs import ( "bufio" "io" "os/exec" "strings" "github.com/rubyist/tracerx" ) type wrappedCmd struct { Stdin io.WriteCloser Stdout *bufio.Reader Stderr *bufio.Reader *exec.Cmd } // startCommand starts up a command and creates a stdin pipe and a buffered // stdout & stderr pipes, wrapped in a wrappe...
package node_checker import "errors" var errCannotLoadData = errors.New("node checker controller: cannot load data form url") var errCannotFindNodes = errors.New("node checker controller: cannot find nodes") var errCannotFindNodeWithKey = errors.New("node checker controller: cannot find node with key") var errCannotL...
package context import ( "github.com/nsqio/go-nsq" "github.com/xozrc/cqrs/command" ordercommand "github.com/xozrc/cqrs/eventsourcing/examples/order/command" messagingnsq "github.com/xozrc/cqrs/messaging/nsq" cqrstypes "github.com/xozrc/cqrs/types" ) type Client interface { CreateOrder() error Cance...
package winprint import ( "syscall" "unsafe" "fmt" ) type PORT_INFO_1 struct { Name *uint16 } type PORT_INFO_2 struct { PortName *uint16 MonitorName *uint16 Description *uint16 PortType uint32 Reserved uint32 } func (t *PORT_INFO_2) GetPortName() string { return utf16PtrToString(t.PortName) } 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 ag...
package main import "fmt" // *********************************** // struct = typed collection of fields // *********************************** type person struct { name string age int } func NewPerson(name string) *person { p := person{name: name} p.age = 20 return &p } func main() { fmt.Println(person{"San...
package git import ( "os/exec" "testing" "github.com/stretchr/testify/assert" "github.com/tilt-dev/tilt/internal/testutils/tempdir" ) func TestNormalizeGitRemoteSuffix(t *testing.T) { assert.Equal(t, normalizeGitRemote("https://github.com/tilt-dev/tilt.git"), normalizeGitRemote("https://github.com/tilt-dev/til...
package main import ( "filestore" "io/ioutil" "os" "time" log "github.com/sirupsen/logrus" ) func main() { var server string if len(os.Args) > 1 { server = os.Args[1] } if server == "" { log.Fatal("Server not provided") } var filename string if len(os.Args) > 2 { filename = os.Args[2] } if fil...
// // ternary search tree // package tst type node2_t struct { hi_kid int eq_kid int lo_kid int key rune value interface{} // prefix terminator } type Tree2_t struct { root []node2_t } type Cursor2_t struct { root []node2_t cur int } const INTMAX = 1<<32 - 1 func (self *Tree2_t) Add(str string, value...
package lib import ( "fmt" "io/ioutil" "log" "net/http" "os" "path/filepath" ) func Check(e error) { if e != nil { log.Fatalln(e) } } func downloadImage(url string) (img []byte, err error) { resp, err := http.Get(url) if err != nil { return } defer resp.Body.Close() img, err = ioutil.ReadAll(resp.Bo...
package models import ( "api/provider" "api/utils/inject" ) var baseProvider *provider.BaseProvider type BaseModels struct { Hello *HelloModel `auto:"helloModel"` Test *TestModel `auto:"testModel"` } func (model *BaseModels) New() { baseProvider = provider.GetProvider() inject.Register("baseModel", model) ...
package banks_db import "regexp" var rawPaymentSystems = map[string]string{ "electron": `^(4026|417500|4405|4508|4844|4913|4917)\d+$`, "maestro": `^(5018|5020|5038|5612|5893|6304|6759|6761|6762|6763|0604|6390)\d+$`, "dankort": `^(5019)\d+$`, "interpayment": `^(636)\d+$`, "un...
// 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, ...
package descriptor import ( "fmt" maia "github.com/grpc-custom/maia/proto" ) func (r *Registry) Component(typ maia.ComponentType) (*Component, error) { comp, ok := r.components[typ] if !ok { return nil, fmt.Errorf("no found %s", typ) } return comp, nil }
package gosignaler import ( "os" "sync" "syscall" "testing" "time" ) type testSignalReceiver struct { wg *sync.WaitGroup ChkSignal os.Signal } func (t *testSignalReceiver) Receive(signal os.Signal) (proceed bool) { t.ChkSignal = signal return } func (t *testSignalReceiver) WaitGroup() (ret *sync.Wai...
package gorm_test import ( "testing" "github.com/go-test/deep" ints "github.com/porter-dev/porter/internal/models/integrations" orm "gorm.io/gorm" ) func TestCreateKubeIntegration(t *testing.T) { tester := &tester{ dbFileName: "./porter_create_ki.db", } setupTestEnv(tester, t) initUser(tester, t) initPro...
package util import ( "encoding/json" "io/ioutil" "net/http" "strconv" "time" "regexp" "k8s.io/api/admission/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/klog" ) type ClusterMemberInfo struct { Id int64 Namespace string Cluster string MemberId string MemberName str...
// Homework 8: CLI and Regex // Due April 4, 2017 at 11:59pm package main import ( "flag" "fmt" "regexp" "unicode" ) // Problem 1: CLI // Write a command line interface that prints out sequences of numbers. // // Usage of hw8: // hw8 [flags] # prints out the sequence of numbers, each on a new line // Flags: // ...
package br import ( "regexp" "strconv" "strings" "time" "github.com/AlekSi/pointer" "github.com/olebedev/when/rules" "github.com/pkg/errors" ) func Deadline(s rules.Strategy) rules.Rule { overwrite := s == rules.Override return &rules.F{ RegExp: regexp.MustCompile( "(?i)(?:\\W|^)(dentro\\sde|em)\\s*" ...
// 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 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 crd provides utilities to set up Chrome Remote Desktop. package crd import ( "context" "time" "chromiumos/tast/errors" "chromiumos/tast/local/chrome" "chrom...
package leetcode import ( "github.com/lushenle/leetcode/structures" ) // TreeNode definition for a binary tree node type TreeNode = structures.TreeNode // dfs func zigzagLevelOrder(root *TreeNode) [][]int { var ans [][]int var dfs func(*TreeNode, int) dfs = func(root *TreeNode, level int) { if root == nil { ...
{%- from "../partials/go.template" import messageName -%} {%- from "../partials/go.template" import getOpBinding -%} package asyncapi import ( "asyncapi/transport" "asyncapi/channel" "asyncapi/message" "asyncapi/operation" "errors" ) type Controller struct { Transport transport.PubSub contentWriters map[strin...
package main import( "golang.org/x/tour/reader" "fmt" ) type MyReader struct{} func (reader MyReader) Read(b []byte) (int, error) { if len(b) == 0 { return 0, fmt.Errorf("Buffer is empty") } for i, _ := range b { b[i] = 'A' } return 1, nil } func main() { reader.Valid...
package contract import ( "bytes" "encoding/json" "fmt" "github.com/hekonsek/paymentapp/api" "github.com/hekonsek/paymentapp/payments" "github.com/stretchr/testify/assert" "net/http" "os" "path/filepath" "testing" "github.com/pact-foundation/pact-go/dsl" "github.com/pact-foundation/pact-go/types" ) var d...
package main import "fmt" func main() { somar := func(a, b float64) float64 { return a + b } multiplicar := func(a, b float64) float64 { return a * b } fmt.Println(somar(3, 4)) fmt.Println(multiplicar(3, 4)) }
package main import "fmt" /* Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of list. Example: Input: 1->2->3->4->5->NULL, m = 2, n = 4 Output: 1->4->3->2->5->NULL */ /** * Definition for singly-linked list. */ type ListNode struct { Val int Next *ListNode } func ...
package server import ( "encoding/hex" "encoding/json" "errors" "fmt" "kto/block" "kto/blockchain" "kto/p2p/node" "kto/transaction" "kto/txpool" "kto/until/logger" "strconv" "github.com/buaazp/fasthttprouter" "github.com/valyala/fasthttp" ) type resp struct { Address string `json:"address"` Hash st...
/* * */ package sync import ( "encoding/base64" "errors" "fmt" "strings" "time" "io/ioutil" "gopkg.in/yaml.v2" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ecr" "github.com/xelalexv/dregsy/internal/p...
package sma import ( "context" "fmt" "sync" "sync/atomic" "time" "github.com/evcc-io/evcc/util" "gitlab.com/bboehmke/sunny" ) const udpTimeout = 10 * time.Second // map of created discover instances var discoverers = make(map[string]*Discoverer) var discoverersMutex sync.Mutex // initialize sunny logger onl...
package leetcode import "strings" func lengthLongestPath(input string) int { if !hasFile(input) { return 0 } return llp("\n"+input) - 1 } func max(a, b int) int { if a > b { return a } return b } func nextCR(path string, idx int) int { var i int for i = idx + 1; i < len(path); i++ { if path[i:i+1] =...
package main import ( "database/sql" "flag" "fmt" "github.com/360EntSecGroup-Skylar/excelize" "log" "os" "path/filepath" "strconv" "strings" ) import _ "github.com/go-sql-driver/mysql" type Structure struct { ColumnName sql.NullString DataType sql.NullString CharacterMaximumLeng...
package main import ( "fmt" "io" "io/ioutil" "os/exec" "strconv" "sync" ) func main() { // cmd := exec.Command("ls", "-lrth", "/tmp/") cmds := make(map[*exec.Cmd]io.ReadCloser) for i := 0; i < 10; i++ { cmd := exec.Command("sleep", strconv.Itoa(i)) outPipe, _ := cmd.StdoutPipe() cmd.Start() cmds[c...
package rate_type import ( "sync" "vcm/api" ) type XEM string func (x *XEM) UpdateRate(wg *sync.WaitGroup) { defer wg.Done() rate, err := api.FetchRate("xem_jpy") if err != nil { panic(err) } *x = XEM(rate) }
package slack import ( "bytes" "encoding/json" "fmt" "io" "net/http" "net/http/httputil" ) const ( baseURL = "https://slack.com/api/" ) // Client is a client that authenticates requests to the Slack api. type Client struct { Token string BaseURL string } // NewClient creates a new slack client. func NewC...
// Copyright 2020 The Cockroach Authors. // // Licensed as a CockroachDB Enterprise file under the Cockroach Community // License (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // https://github.com/cockroachdb/cockroach/blob/master/li...
// 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 example import ( "context" "time" "chromiumos/tast/local/profiler" "chromiumos/tast/testing" ) func init() { testing.AddTest(&testing.Test{ Func: Profil...
package main /* Go does not have classes. However, you can define methods on types. A method is a function with a special receiver argument. The receiver appears in its own argument list between the func keyword and the method name. In this example, the Abs method has a receiver of type Vertex named v. */ import (...
package cache import ( "fmt" "testing" "time" ) func TestExpired(t *testing.T) { e := entry{expiration: time.Second} if e.IsExpired() { t.Fatal() } } func TestList(t *testing.T) { c := NewMemCache() c.Set("1", "1", 0) c.Set("2", "2", 0) c.Set("3", "3", 0) c.List(func(k string, v CacheEntry) bool { f...
package operaads import ( "encoding/json" "errors" "fmt" "net/http" "strings" "text/template" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/macros" "github.com/prebid/prebid-server/openrtb_ex...
/* Copyright 2021 The Skaffold 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...
// 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...
package odoo import ( "fmt" ) // AccountFiscalPositionAccountTemplate represents account.fiscal.position.account.template model. type AccountFiscalPositionAccountTemplate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` AccountDestId *Many2One `xmlrpc:"account_dest_id,omptempty"` AccountSrcId ...
package structs import ( "time" "github.com/garyburd/redigo/redis" "github.com/jinzhu/gorm" "github.com/patrickmn/go-cache" ) var ( AdscoopsDB *gorm.DB AdscoopsRealtimeDB *gorm.DB BroadvidDB *gorm.DB RedisPool *redis.Pool Cache *cache.Cache ) func init() { Cache = cac...
package yixia import ( "fmt" "regexp" "videocrawler/clients" "videocrawler/common/util" "videocrawler/crawler" "github.com/buger/jsonparser" "github.com/fatih/color" ) type Miaopai struct { *crawler.CrawlerNet Client *clients.CrClient streams crawler.StreamSet videoId string title string pageUrl str...
package application const HeaderUserID = "X-UserID" const HeaderFirebaseToken = "X-FirebaseToken"
package kubernetes import ( "encoding/json" "fmt" "regexp" "strings" "sync" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "github.com/kiali/kiali/config" "github.com/kiali/kiali/log" ) var ( portNameMatcher = regexp.MustCompile(`^[\-].*`)...
package user import ( "net/http" "project/database" "project/packages/handlers/response" "strconv" "github.com/gorilla/mux" ) func GetInfoByID(w http.ResponseWriter, r *http.Request) { //get ID order vars := mux.Vars(r) id, _ := strconv.Atoi(vars["userId"]) //connect database db := database.ConnectToDatab...
package db import ( "github.com/jinzhu/gorm" "logger" ) func TxBegin() (tx *gorm.DB, err error) { db_handle, err := GetDB() if err != nil { logger.Errorln(err) return } tx = db_handle.Begin() return tx, nil } func TxEnd(tx *gorm.DB, exception error) (err error) { if exception != nil { logger.Errorln(...
/* * 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...
package handlers import ( "net/http" "github.com/gorilla/mux" "github.com/kiali/kiali/log" "github.com/kiali/kiali/prometheus" ) func NamespaceList(w http.ResponseWriter, r *http.Request) { business, err := getBusiness(r) if err != nil { log.Error(err) RespondWithError(w, http.StatusInternalServerError, ...
// 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 main import ( "fmt" "time" ) func main() { c := make(chan bool, 1) go func() { excuteTask(c) }() v := <-c fmt.Println("complete?", v) } func excuteTask(complete chan bool) { for i := 0; i < 10; i++ { fmt.Println("sleeping for a sec", i) time.Sleep(1 * time.Second) if i == 6 { fmt.Println...
package main import( "github.com/forj-oss/goforjj" ) //ProjectStruct (TODO) type ProjectStruct struct { Name string Flow string `yaml:",omitempty"` Description string `yaml:",omitempty"` Disabled bool `yaml:",omitempty"` IssueTracker bool `yaml:"issue_tracker,omitempty"` Users map[...
package main import ( "bufio" "fmt" "io" "log" "os" "sort" "strconv" ) func readIntsFromFile(r io.Reader) ([]int, error) { var result []int scanner := bufio.NewScanner(r) scanner.Split(bufio.ScanWords) for scanner.Scan() { value, err := strconv.Atoi(scanner.Text()) if err != nil { return result, er...
package editorapi import ( "editorApi/commons" "editorApi/init/mgdb" "editorApi/requests" "editorApi/service" "editorApi/tools/helpers" "strings" "github.com/gin-gonic/gin" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" ) // @Tags Sentence(句子接口) // @Summary 句子列表 // @Descript...
package pkg import ( "sort" bolt "github.com/coreos/bbolt" ) // Blockchain is the list of linked blocks type Blockchain struct { last []byte db *bolt.DB } // NewBlockchain initializes a new blockchain func NewBlockchain(db *bolt.DB) (*Blockchain, error) { var last []byte err := db.Update(func(tx *bolt.Tx) e...