text
stringlengths
11
4.05M
package service import ( "context" "github.com/arabian9ts/geekfes/domain/model" "github.com/arabian9ts/geekfes/domain/repository" ) type Service interface { DatasetService SeriesService SeasonService EpisodeService } type DatasetService interface { GetDataset(ctx context.Context, seriesID string) (model.Dat...
package handler import ( "fmt" "strings" "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" ) const ( aliasHeader = "X-Original-URI" realIpHeader = "X-Real-IP" forwardedHeader = "X-Forwarded-For" UriHeader = "Requested-Uri" ) func (h *Handler) auth(c *gin.Context) { channelAllias := c.Get...
package base import ( "context" "encoding/json" "strings" "sync" "github.com/rs/zerolog/log" "github.com/elastic/go-elasticsearch/v7" "github.com/elastic/go-elasticsearch/v7/esapi" ) func es1(es *elasticsearch.Client) { res, err := es.Index( "test", // Index name strings...
/* Project Euler - Problems Main function to execute completed problems. When a problem is done, add its case here. */ package euler // Return the result of the specified problem func Problems(num int) string { switch num { case 6: return Euler006() case 13: return Euler013() case 14:...
//go:build tools // +build tools package ledger // import _ "github.com/99designs/gqlgen"
package column import ( "fmt" "io" "github.com/vahid-sohrabloo/chconn/v2/internal/helper" "github.com/vahid-sohrabloo/chconn/v2/internal/readerwriter" ) type stringPos struct { start int end int } // StringBase is a column of String ClickHouse data type with generic type type StringBase[T ~string] struct { ...
package main import ( "context" "fmt" "log" sms "github.com/klaus01/GoMicro_LBSServer/api/sms/proto" smscode "github.com/klaus01/GoMicro_LBSServer/srv/smscode/proto" yuntongxun "github.com/klaus01/GoMicro_LBSServer/srv/yuntongxun/proto" "github.com/klaus01/GoMicro_LBSServer/utils" "github.com/micro/go-micro/...
package decoder import ( "bytes" "compress/gzip" "io" ) // tmplsrc returns raw, uncompressed file data. func tmplsrc() []byte { gz, err := gzip.NewReader(bytes.NewBuffer([]byte{ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x00, 0xff, 0xbc, 0x57, 0xdf, 0x4f, 0xe3, 0x38, 0x10, 0x7e, 0x4e, 0xfe, 0x8a, 0x21, ...
package sinks import ( "github.com/stretchr/testify/assert" "io/ioutil" "os" "testing" "time" ) func TestFileSink_Dump_NoLimits(t *testing.T) { sink := NewFileSink(FileSinkConfig{}, nil) person1 := &person{ Id: "1", Name: "Metuselah", Age: 700, } person2 := &person{ Id: "2", Name: "Noah", Ag...
package main import "fmt" func binary(arr []int, num int) int { var k = len(arr) / 2 for i := 0; i < len(arr); { switch { case arr[i] == num: { return i } case arr[i] < num: { i += k } case arr[i] > num: { i -= k } } if k > 1 { k = k / 2 } } return -1 } func main() ...
package main import ( "flag" "log" "math/rand" "github.com/gobridge-kr/bot-sample/internal" "github.com/sbstjn/hanu" ) const version = "0.0.1" var tokenContainer = bot.NewContainer("") func init() { var token string flag.StringVar(&token, "token", "", "Slack bot API token") flag.Parse() tokenContainer.Set...
// Copyright 2017 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, ...
/** * (C) Copyright IBM Corp. 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 or agree...
package Surrounded_Regions func solve(board [][]byte) { if len(board) == 0 { return } visited := make([][]bool, len(board)) for i, rows := range board { visited[i] = make([]bool, len(rows)) } var mark func(row, col int) mark = func(row, col int) { if row < 0 || col < 0 || row >= len(board) || col >= len...
package wire import ( "errors" "strings" "testing" "github.com/moov-io/base" "github.com/stretchr/testify/require" ) // mockSenderDepositoryInstitution creates a SenderDepositoryInstitution func mockSenderDepositoryInstitution() *SenderDepositoryInstitution { sdi := NewSenderDepositoryInstitution() sdi.Sender...
// Package hex implements hexadecimal encoding and decoding. package hex import ( "encoding/hex" "fmt" "regexp" "strings" ) var ( pat = regexp.MustCompile("[0-9a-z]{8} ([0-9a-z ]+) ") ) // Dump takes a byte slice and transforms it func Dump(data []byte) string { in := hex.Dump(data) out := "" matches := pat...
package api import ( "context" "fmt" "log" "net/http" "github.com/edoardo849/bezos/pkg/order" "github.com/gorilla/mux" ) const ( // apiVersion is version of API is provided by server apiVersion = "v1" ) // New Creates a new handler func New(os order.Service, r *mux.Router, stopChan chan struct{}) *Server {...
package main import ( "fmt" ) func main() { student := []string{} // There is an underlying data structure, but there is nothing to reference - it's not nil, but it's not ready. students := [][]string{} // There is an underlying data structure, but there is nothing to reference - it's not nil, but it's not ready. ...
package main import ( "fmt" ) func seasonGenerator(month int) string { switch month { case 3, 4, 5: // * no more breaks return "Spring" case 6, 7, 8: return "Summer" case 9, 10, 11: return "Fall" case 12, 1, 2: return "Winter" default: } return "none" } func main() { fmt.Println(seasonGenerator(10)...
package mapqueryparam import ( "encoding/json" "errors" "fmt" "net/url" "reflect" "strconv" "strings" "time" ) // EncodeValues takes a input struct and encodes the content into the form of a set of query parameters. // Input must be a pointer to a struct. Same as Encode. func EncodeValues(v interface{}) (url....
package rtsp import ( "fmt" "log" "net" "os" "sync" ) type Server struct { SessionLogger TCPListener *net.TCPListener TCPPort int Stoped bool pushers map[string]*Pusher // Path <-> Pusher pushersLock sync.RWMutex } var Instance *Server = &Server{ SessionLogger: SessionLogger{log.New(os.Stdou...
package main import ( "bufio" "container/heap" "fmt" "log" "os" "sort" ) type intHeap []int func (h intHeap) Len() int { return len(h) } func (h intHeap) Less(i, j int) bool { return h[i] < h[j] } func (h intHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] } func (h *intHeap) Push(x interface{}) {...
//Package ingest provides the Ingest interface package ingest import ( "github.com/littlebunch/gnutdata-bfpd-api/ds" ) // Counts holds counts for documents loaded during an ingest // process type Counts struct { Foods int `json:"foods"` Servings int `json:"servings"` Nutrients int `json:"nutrients"` Other ...
package main import ( "fmt" ) func sequenceEquation(px []int) (py []int) { d := map[int]int{} f := map[int]int{} for i, v := range px { d[i+1] = v } for k, v := range d { f[v] = k } for i := 0; i < len(px); i++ { py = append(py, f[f[i+1]]) } return py } func main() { x := []int{2, 3, 1} fmt.Println...
package main import "fmt" type Contact struct { greeting string name string } // FUNCTIONS ARE TYPES // functions in go are types // functions behave as types in go // you can pass functions around just as you'd pass types around // pass functions just like any other argument / parameter // STEP 1: // create ...
package ellipsis import ( "github.com/ajduncan/vulcan/internal/vulcan" "github.com/ajduncan/vulcan/pkg/service" ) func RunEllipsisService() { address := vulcan.Getenv("BEACON_HOST", "127.0.0.1") + ":" + vulcan.Getenv("BEACON_PORT", "8003") vs := service.NewVulcanService("ellipsis", address) vs.RunVulcanServer() ...
package tasks import ( "github.com/jsm/gode/worker/tasknames" ) // TaskMap correlates task names to their respective functions var TaskMap = map[string]interface{}{ tasknames.Test: test, } // Test worker availability func test() (string, error) { return "tested", nil }
package v2 import ( "encoding/hex" "errors" "log" "net/http" "net/url" "github.com/labstack/echo/v4" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/handler/v2/openapi" "github.com/traPtitech/trap-collection-server/src/service" ) type GameFi...
package main import ( "fmt" ) type Saiyan struct { Name string Power int } func main() { saiyans := make([]Saiyan, 0, 10) saiyans = append(saiyans, Saiyan{"Goku", 9000}) fmt.Println(extractPowers(&saiyans)) } func extractPowers(Saiyans []*Saiyan) []int { powers := make([]int, 0, len(Saiyans)) for _, saiya...
package scheduler import "logserver/slaver/common" type Scheduler struct { logCount chan int JobEventChan chan *common.JobEvent JobWorkTable map[string]*common.JobWorkInfo } var Gscheduler *Scheduler
package e2e import ( "fmt" "os" "os/user" "path/filepath" "testing" appset "github.com/openshift/client-go/apps/clientset/versioned" buildset "github.com/openshift/client-go/build/clientset/versioned" imageset "github.com/openshift/client-go/image/clientset/versioned" projectset "github.com/openshift/client-...
// Work in progress package optimga //TODO type Roulette struct { // Size int //} // Roulette selection, select 1 parent with better chance to be selected for the best individual // However, the underperforming individuals have a small chance to be selected too to preserve a diversity // TODO Local normalisation of ...
package main import "fmt" func main() { for i := 60; i < 122; i++ { fmt.Printf("decimal : %d\tbinary : %b\thexa : %x\t utf-8 : %q \nt", i, i, i, i) } }
package marshal import ( "bytes" "encoding/json" ) func PureMarshal(t interface{}) ([]byte, error) { buf := bytes.NewBuffer([]byte{}) enc := json.NewEncoder(buf) enc.SetEscapeHTML(false) err := enc.Encode(t) return buf.Bytes(), err } func PureMarshalIndent(t interface{}, prefix, indent string) ([]byte, error)...
/* 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 redisstream import ( "net" "strconv" "strings" "log" "sort" "time" "github.com/pkg/errors" _redis "github.com/go-redis/redis" "openreplay/backend/pkg/queue/types" ) type idsInfo struct{ id []string ts []int64 } type streamPendingIDsMap map[string]*idsInfo type Consumer struct { redis ...
/* * Copyright 2019 Open Networking Foundation * * 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 stringutil import "sync" type StringSet = Set type Set struct { sync.Once Set map[string]struct{} } func (s *Set) Add(vs ...string) { if len(vs) == 0 { return } s.Do(func() { if s.Set == nil { s.Set = make(map[string]struct{}, len(vs)) } }) for _, v := range vs { s.Set[v] = struct{}{} ...
package ui import "image" // Point is a absolute position type Point image.Point // In returns true if `p` is inside of `rect` func (p *Point) In(rect image.Rectangle) bool { return image.Point(*p).In(rect) }
package factory import ( "context" "github.com/loft-sh/devspace/pkg/devspace/analyze" "github.com/loft-sh/devspace/pkg/devspace/build" "github.com/loft-sh/devspace/pkg/devspace/config/loader" "github.com/loft-sh/devspace/pkg/devspace/config/localcache" "github.com/loft-sh/devspace/pkg/devspace/config/versions/la...
package garbagecollection import ( "context" "fmt" "time" "github.com/go-logr/logr" "github.com/hashicorp/go-multierror" "sigs.k8s.io/controller-runtime/pkg/reconcile" "github.com/gardener/test-infra/pkg/util/s3" argov1 "github.com/argoproj/argo/v2/pkg/apis/workflow/v1alpha1" corev1 "k8s.io/api/core/v1" m...
package util import ( "github.com/360EntSecGroup-Skylar/excelize" "log" "strconv" ) // ReadExcel读取一个excel文件,返回一个map,key为姓名,value为学号 // 注:部分人有不写学号的习惯,所以用学号做key会影响后续处理 func ReadExcel(name string) map[string]string { f, err := excelize.OpenFile(name) if err != nil { log.Fatalf("打开excel文件失败:%s", err.Error()) } u...
package graphql_endpoint type Config struct { Elastic elasticSearch `toml:"elastic"` Graphql graphqlServer `toml:"graphql"` } type elasticSearch struct { Url string } type graphqlServer struct { Port int }
/* Copyright 2019 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 2020 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) SAS Institute 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 agre...
package main import ( "fmt" "sort" ) /* Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. Example: nums = [1, 2, 3] target = 4 The possible combination ways are: (1, 1, 1, 1) (1, 1, 2) (1, 2, 1) (1, 3) (2, ...
package controller import ( "context" "employees/models" "github.com/gin-gonic/gin" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "log" "net/http" "strconv" ) var collection *mongo.Collection var ctx context.Context func EmployeeCollection(c *mongo.Database) { collection = c.Collect...
package main import ( "context" "grpc/payload" "log" "net" "google.golang.org/grpc" ) func errorHandel(msg string, err error) { if err != nil { log.Fatalf("[x] error %s : %v", msg, err) } } func main() { lis, err := net.Listen("tcp", ":9000") errorHandel("can't listen tcp connection", err) grpcServer :=...
package model import ( "time" "code.gitea.io/sdk/gitea" "github.com/google/go-github/v47/github" "github.com/xanzy/go-gitlab" ) type User struct { Common Login string `json:"login,omitempty"` // 登录名 AvatarURL string `json:"avatar_url,omitempty"` // 头像地址 Name string `json:"name,omitempty"` ...
package client import ( "bytes" "encoding/json" "fmt" "github.com/commitdev/kafka-connect/config" "github.com/commitdev/kafka-connect/pkg/utils" "io/ioutil" "log" "net/http" "net/url" ) //KafkaConnectClient implements functions interacting with kafka connect configurations. type KafkaConnectClient interface ...
// 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 useractions // AttributeTestScenario describes the test scenario that the user action is running in. const AttributeTestScenario string = "TestScenario" // Attribut...
package cmd import ( "fmt" "io/ioutil" "os" "os/exec" "path/filepath" "github.com/puppetlabs/wash/cmd/internal/server" cmdutil "github.com/puppetlabs/wash/cmd/util" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) // Create an executable file at the given path that invokes the given wash subcomma...
package main import "fmt" func checkValidString(s string) bool { l, h := 0, 0 for _, c := range s { switch c { case '(': l, h = l+1, h+1 case ')': l, h = l-1, h-1 case '*': l, h = l-1, h+1 } if h < 0 { return false } if l < 0 { l = 0 } } return l <= 0 && 0 <=...
package pel_test import ( "github.com/reiver/go-pel" "image" "math" "math/rand" "time" "testing" ) func TestRGBA_At_alpha255(t *testing.T) { randomness := rand.New(rand.NewSource( time.Now().UTC().UnixNano() )) for testNumber:=0; testNumber<10; testNumber++ { var x,y int { x = randomness.Int() ...
package main import "fmt" func main() { for i := 0; i < 15; i++ { fmt.Printf("%d in for loop\n", i) } i := 0 START: if i < 15 { fmt.Printf("%d in goto\n", i) i++ goto START } }
package nebula import ( "bytes" "encoding/binary" "errors" "math" "net" "testing" "time" "github.com/rcrowley/go-metrics" "github.com/slackhq/nebula/cert" "github.com/slackhq/nebula/config" "github.com/slackhq/nebula/firewall" "github.com/slackhq/nebula/iputil" "github.com/slackhq/nebula/test" "github.c...
package app import ( "bytes" "context" "io" "net/http" "testing" "testing/fstest" "time" "github.com/dikaeinstein/downloader/pkg/hash" "github.com/dikaeinstein/godl/internal/pkg/downloader" "github.com/dikaeinstein/godl/pkg/fsys" "github.com/dikaeinstein/godl/test" ) type fakeHashVerifier struct{} func ...
package errors import "errors" var ( ERR_ASSET_NAME_INVALID = errors.New("asset name invalid, too long") ERR_ASSET_PRECISION_INVALID = errors.New("asset precision invalid") ERR_ASSET_AMOUNT_INVALID = errors.New("asset amount invalid") ERR_ASSET_CHECK_OWNER_INVALID = errors.New("asset owner invalid")...
package main import "fmt" func main() { // indentation for illustration n1 := Node{data:1} n2 := Node{data:2} n3 := Node{data:3} n6 := Node{data:31} n7 := Node{data:32} n4 := Node{data:4} n5 := Node{data:5} n1.addChild(&n2) n1.addChild(&n3) n3.addChild(&n6) n3.addChild(&n7) n1.addChild(&n4) n1....
package sessionresolver import ( "encoding/json" ) // codec is the codec we use. type codec interface { // Encode encodes v as a stream of bytes. Encode(v interface{}) ([]byte, error) // Decode decodes b into a stream of bytes. Decode(b []byte, v interface{}) error } // getCodec always returns a valid codec. f...
package decorator import ( "io" "testing" "github.com/docker/libtrust" "github.com/docker/distribution/digest" "github.com/docker/distribution/manifest" "github.com/docker/distribution/storage" "github.com/docker/distribution/storagedriver/inmemory" "github.com/docker/distribution/testutil" ) func TestRegis...
package types import ( "fmt" ) // CheckMapType checks the type of m[k] is t, and return the value if yes, // or return an error if not. // // If m is nil, return an error. // // The function uses VerifyType to verify the type, that's, VerifyType(m[k], t), // so for t, see VerifyType. func CheckMapType(m map[string]i...
// +build windows darwin linux,!arm package sensor import ( "math/rand" "time" ) const ( pulseDelay = 10 * time.Microsecond ) //DistanceSensor interface for an ultra sound sensor type DistanceSensor interface { Distance() (float64, error) } type HCSRO4Sensor struct { echo, trigger uint8 } func NewHCSRO4Senso...
// 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 protocol import ( "CMDB/api/conf" hostAPI "CMDB/api/pkg/host/http" "context" "fmt" "github.com/infraboard/mcube/http/middleware/cors" "github.com/infraboard/mcube/logger" "github.com/infraboard/mcube/logger/zap" "github.com/julienschmidt/httprouter" "net/http" "time" ) // NewHTTPService 构建函数 func N...
package subcast import ( "io/ioutil" "text/scanner" "subc/compile/arch/amd64" "subc/parse" "subc/scan" "subc/types" ) func Fuzz(data []byte) int { r := scan.StringReader(scanner.Position{ Filename: "fuzz", Line: 1, Column: 1, }, string(data), false) scanner := scan.New(scan.DefaultConfig, "fuzz...
package gerror import ( "encoding/json" "errors" "fmt" "testing" ) var ( baseError = errors.New("test") ) func Benchmark_New(b *testing.B) { for i := 0; i < b.N; i++ { New("test") } } func Benchmark_Newf(b *testing.B) { for i := 0; i < b.N; i++ { Newf("%s", "test") } } func Benchmark_Wrap(b *testing.B...
package utils var Version = "v1.0"
package reports import ( "context" "database/sql" "time" "github.com/pganalyze/collector/input/postgres" "github.com/pganalyze/collector/output/pganalyze_collector" "github.com/pganalyze/collector/state" "github.com/pganalyze/collector/util" "google.golang.org/protobuf/types/known/timestamppb" ) // BloatRepo...
package dashrates import ( "encoding/json" "io/ioutil" "net/http" "time" ) // BitbnsAPI implements the RateAPI interface and contains info necessary for // calling to the public Bitbns price ticker API. type BitbnsAPI struct { BaseAPIURL string PriceTickerEndpoint string } // NewBitbnsAPI is a constru...
// Copyright 2021 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 2014 mqant Author. 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 server import ( "chaplapp/provider" "chaplapp/renderer" "chaplapp/strategy" "log" "net/http" ) type handler struct { meetingProvider provider.MeetingProvider chairmanProvider provider.ChairmanProvider strategy strategy.PlanningStrategy renderer renderer.AssignmentListRenderer } func...
// Copyright 2017 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 model import ( "fmt" "github.com/grafana/tempo/pkg/tempopb" "github.com/gogo/protobuf/proto" ) // CurrentEncoding is a string representing the encoding that all new blocks should be created with // "" = tempopb.Trace // "v1" = tempopb.TraceBytes const CurrentEncoding = "v1" // TracePBEncoding is a s...
package main import "fmt" func switchOnType(x interface{}) { switch x.(type) { // chequea el tipo de x case int: fmt.Println("int") case string: fmt.Println("string") default: fmt.Println("unknown") } } func main() { switchOnType(5) switchOnType("blebleble") switchOnType('f') }
// Copyright 2018 The adeia authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package adeia_test import ( "testing" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/pkg/errors" "github.com/seibert-media/adeia" ...
package dev import ( devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context" "github.com/loft-sh/devspace/pkg/devspace/pipeline/types" "github.com/loft-sh/devspace/pkg/devspace/server" "github.com/loft-sh/devspace/pkg/util/log" "github.com/mgutz/ansi" "github.com/sirupsen/logrus" ) func UI(ctx devspa...
package selector import ( "fmt" "strings" "github.com/layer5io/meshery/models/pattern/core" ) const ( CoreResource = "pattern.meshery.io/core" MeshResource = "pattern.meshery.io/mesh/workload" K8sResource = "pattern.meshery.io/k8s" ) type Helpers interface { GetServiceMesh() (name string, version string) G...
package main import ( "fmt" ) func main() { array1 := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} array2 := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} fmt.Printf("Original array :%v", array1) leftShiftedArray := leftShiftArray(array1, 3) rightShiftedArray := rightShiftArray(array2, 3) fmt.Println("") fmt.Printf("Left shif...
package gohotdraw import ( _ "fmt" ) type DrawingView interface { GetDrawing() Drawing SetDrawing(drawing Drawing) GetGraphics() Graphics SetGraphics(g Graphics) SetEditor(editor DrawingEditor) Add(figure Figure) Figure Remove(figure Figure) Figure AddFigureSelectionListener(l FigureSelectionListener) Remo...
package models import ( "github.com/inimbir/onpu-data-grabber/app/clients" ) type HashTag struct { Value string } func NewHashtag() *HashTag { return &HashTag{} } var hashTagsChainOfResponsibilities = &IsValidHandler{ next: &IsNotExistsHandler{ next: &PrepareDataHandler{ next: &CheckSimilarityHandler{ ...
package main import ( "fmt" "os" "strconv" "strings" "encoding/csv" ) const Letters = "abcdefghijklmnop" const LetterCount = len(Letters) const Dances = 1000000000 var firstPosition = 0 var letterMap = make(map[string]int) var positionMap = make(map[int]string) func init() { for i, c := range Letters { lett...
package cli import ( "github.com/thePhilGuy/grove/git" urfaveCli "gopkg.in/urfave/cli.v1" ) func Initialize() *urfaveCli.App { grover := urfaveCli.NewApp() grover.Name = "grove" grover.Usage = "Work across multiple git repositories" grover.Version = "0.0.1" grover.Commands = []urfaveCli.Command{ { Name: ...
package base import ( "jean/rtda/jvmstack" ) func Branch(frame *jvmstack.Frame, offset int) { pc := frame.Thread().PC() nextPC := pc + offset frame.SetNextPC(nextPC) }
// 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 arc import ( "context" "regexp" "strings" "time" "chromiumos/tast/common/testexec" "chromiumos/tast/errors" "chromiumos/tast/testing" ) const ( // Removabl...
package main import ( "bytes" "fmt" ) func comma(s string) string { var n int = len(s) var tmp bytes.Buffer var begin = 0 if n%3 == 0 { begin = 3 } else { begin = n % 3 } var a int = 0 var i int = 0 for i = begin; i < n; i += 3 { tmp.WriteString(s[a:i]) tmp.WriteString(",") a = i } tmp.WriteStr...
package main import "fmt" type employee struct { salary float32 } func (em *employee) giveRaise(per float32) float32 { return em.salary * (1.0 + per) } func main() { emp1 := employee{3000.0} fmt.Println(emp1.giveRaise(0.8)) emp2 := &employee{18000.0} fmt.Println(emp2.giveRaise(0.8)) }
package main import ( "designPattern/AAA_singleton/emperor2" ) func main() { er := emperor2.GetInstance() er.Name = "haha" er.Say() for i:=0; i<3; i++{ er := emperor2.GetInstance() er.Say() } }
package download import ( "net/http" "spider/utils/context" ) type Downloader interface { Download(*context.Request) (*context.Response, error) } type PageDownloader struct { client *http.Client } func NewPageDownloader(client *http.Client) *PageDownloader { if client == nil { client = &http.Client{} } ret...
package main import ( "flag" "zenhack.net/go/tempest/internal/common/types" "zenhack.net/go/tempest/internal/server/database" "zenhack.net/go/tempest/internal/server/tokenutil" "zenhack.net/go/util" ) var ( typ = flag.String("type", "", "credential type to use") scopedID = flag.String("id", "", "type-spe...
package main import ( "encoding/csv" "fmt" "github.com/tebeka/selenium/chrome" "log" "os" "strings" "time" "github.com/tebeka/selenium" "gopkg.in/gomail.v2" ) const ( port = 8066 ) var webDriver selenium.WebDriver var service *selenium.Service const urlBeijing = "https://www.che168.com/beijing/list/#pvar...
package main import ( "fmt" "time" ) func main() { //var a chan int //a = make(chan int) //fmt.Println(a) // Send //ch <- val // Receive //val := <- ch ch := make(chan int, 1024) fmt.Println("Sending value to channel") go send(ch, 42) fmt.Println("Receiving from channel") go receive(ch) time.Slee...
package vector import "math" var ( degreesToRadias = math.Pi / 180 ) // NewVector creates a new vector func NewVector(vals ...float64) Vector { return Vector{vals} } // Vector is the vector object type Vector struct { vals []float64 } // GetVals returns the values of the vector func (v1 Vector) GetVals() []floa...
package pkg // InvalidBlockError is raised when we find an invalid block type InvalidBlockError struct { message string block Block } // NewInvalidBlockError returns an error that formats as the given text. func NewInvalidBlockError(message string, block *Block) *InvalidBlockError { return &InvalidBlockError{ ...
package main import ( "syscall" "unsafe" ) // precision timing var ( modkernel32 = syscall.NewLazyDLL("kernel32.dll") queryPerformanceFrequencyProc = modkernel32.NewProc("QueryPerformanceFrequency") queryPerformanceCounterProc = modkernel32.NewProc("QueryPerformanceCounter") ) // now returns...
// Copyright (c) 2020 StackRox 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 ...
package main import ( "fmt" "net/http" ) const html = ` <html> <head> </head> <body> <h3>Congrats, GO app was successfully configured!</h3> The environment was configured using this installation script: <a target="_blank" href="https://github.com/bykovme/webgolangdo">github.com/bykovme/webgolangdo</a> <br> Find mor...
package kgo import ( "archive/tar" "compress/gzip" "crypto/md5" "encoding/base64" "encoding/hex" "fmt" "io" "io/ioutil" "mime" "net/http" "os" "path" "path/filepath" "regexp" "strings" "syscall" ) // GetExt 获取文件扩展名,不包括点"." func (kf *LkkFile) GetExt(path string) string { suffix := filepath.Ext(path) ...