text stringlengths 11 4.05M |
|---|
package tests
import (
"testing"
"github.com/Kaukov/gopher-translator/utils"
)
func TestTranslator(t *testing.T) {
tests := []struct {
input string
expected string
}{
{"hello", "hello"},
{"my", "ymogo"},
{"xray", "gexray"},
{"square", "aresquogo"},
}
for _, test := range tests {
if output, er... |
package main
import (
"2021/shared"
"testing"
)
func TestPart1(t *testing.T) {
input := shared.ReadInput("input")
expected := 0
actual := part1(input)
shared.AssertEqual(t, expected, actual)
}
|
/*
* Copyright © 2018-2022 Software AG, Darmstadt, Germany and/or its licensors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://... |
package alicloud
import (
"fmt"
"os"
"path/filepath"
"testing"
"time"
)
func create_file(name string, size int) (string, error) {
file, err := os.Create(name)
file.Name()
if err != nil {
return "", err
}
defer file.Close()
buf := make([]byte, size)
for i := 0; i < size; i++ {
buf[i] = byte(i)
}
fil... |
package pbkdf2_test
import (
"testing"
"cpl.li/go/cryptor/internal/crypt/ppk"
"cpl.li/go/cryptor/internal/crypt/pbkdf2"
)
const (
password = "testing"
salt = ".-_cryptor,$"
)
func BenchmarkPBKDF2(b *testing.B) {
var key ppk.PrivateKey
for i := 0; i < b.N; i++ {
key = pbkdf2.Key([]byte(password), []byt... |
package models
import (
"encoding/json"
)
type Job struct {
Result struct {
Revision string `json:"revision"`
Spec struct {
Type string `json:"type"`
Cause struct {
Message string `json:"Message"`
User string `json:"User"`
} `json:"cause"`
Spec struct {
Kind string `jso... |
package oidc
import (
"errors"
"fmt"
"strings"
"time"
"github.com/golang-jwt/jwt/v5"
"github.com/ory/fosite"
fjwt "github.com/ory/fosite/token/jwt"
"github.com/ory/x/errorsx"
"golang.org/x/text/language"
"gopkg.in/square/go-jose.v2"
"github.com/authelia/authelia/v4/internal/utils"
)
// IsPushedAuthorized... |
// https://www.careercup.com/question?id=5692469780938752
//
//Question 1.
//You are given a string composed of uppercase English letters (‘A’ through ‘Z’).
//
//Set of letters (‘A’, ‘E’, ‘I’, ‘O’, ‘U’) are called vowels. Other letters are called consonants.
//
//We define foo value of a string as number of pairs of e... |
package main
import (
"fmt"
"net/http"
"encoding/csv"
"io"
"os"
"crypto/tls"
"time"
)
var mapping = make(map[string][]string)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Println("Handling new request")
repos, ok := r.URL.Query()["repo"]
if !ok || len(repos) < ... |
package registry
type Service struct {
Name string
Version string
IP string
Port int
MetaData map[string]string
}
|
package gcmencryptor_test
import (
"crypto/rand"
"crypto/sha256"
b64 "encoding/base64"
"io"
"github.com/cloudfoundry-incubator/cloud-service-broker/internal/encryption/gcmencryptor"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("GCMEncryptor", func() {
var encryptor gcmencryptor.GC... |
package model
// Service -- Representing service request
type Service struct {
ID uint64 `json:"_id"`
RequestID uint64 `json:"requestId"`
Status string `json:"status"`
VesselName string `json:"vesselName"`
ServiceType string `json:"serviceType"`
DataAgent string `json:"dataAgent"`
Cargo ... |
// Copyright Amazon.com Inc. or its affiliates. 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. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license" file ... |
package main
func main() {
removeDuplicates([]int{0, 0, 1, 1, 1, 2, 2, 3, 3, 4})
}
func removeDuplicates(nums []int) int {
//因为已经排好序,那么使用直接遍历即可
if len(nums) == 0 {
return 0
}
temp := nums[0]
for i := 1; i < len(nums); {
if nums[i] == temp {
//重复
nums = append(nums[:i], nums[i+1:]...)
} else {
tem... |
package poker
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"net/http/httptest"
"os"
"reflect"
"strings"
"testing"
"time"
)
type SpyGame struct {
NumberOfPlayers int
Winner string
StartCalled bool
FinishCalled bool
BlindAlert []byte
}
func (g *SpyGame) Start(numberOfPlayers int, out io.... |
package analyzer
import (
"fmt"
"path"
"github.com/hermo/registry-check/pkg/composer"
"github.com/hermo/registry-check/pkg/npm"
"github.com/hermo/registry-check/pkg/resolver"
)
// Result represents the findings of a AnalyzeLockfile call
type Result struct {
LockfileType string
NumPackages int
Registries [... |
package file
import "testing"
func TestExist(t *testing.T) {
type args struct {
path string
}
tests := []struct {
name string
args args
want bool
}{
{
name: "exist",
args: args{
path:"E:\\Workspace\\go\\src\\github.com\\ebar-go\\ego\\README.md",
},
want: true,
},
{
name: "notExist... |
package core
import (
"fmt"
)
type Environment struct {
outer *Environment
table map[string]Type
}
func NewEnvironment(outer *Environment, symbols []string, nodes []Type) *Environment {
table := make(map[string]Type)
environment := &Environment{table: table, outer: outer}
for i := 0; i < len(symbols); i++ {
... |
package gosmsc
import (
"fmt"
. "github.com/goodsign/gosmsc/contract"
"sync"
"time"
)
const (
DefaultUpdateInterval = time.Minute
)
// MessageTracker represents a running goroutine that polls SMSC service to track status of sent messages
// which status is pending. This object is created when a goroutine is sta... |
package router
import (
"net/http"
"github.com/Khigashiguchi/khigashiguchi.com/api/infrastructure/repository"
"github.com/Khigashiguchi/khigashiguchi.com/api/interfaces/handlers"
"github.com/gorilla/mux"
)
// New create http routing.
func New(db repository.DBConnector) http.Handler {
r := mux.NewRouter()
// c... |
package zerolog_test
import (
"github.com/rs/zerolog"
zerologadapter "logur.dev/adapter/zerolog"
)
func ExampleNew() {
logger := zerologadapter.New(zerolog.Nop())
// Output:
_ = logger
}
|
package main
import (
"bufio"
"fmt"
"io"
"log"
"math/rand"
"net"
"net/rpc"
)
type Query struct {
d []byte
}
type Reply struct {
d []byte
}
func setError(prev *error, n error) {
if prev == nil {
prev = &n
}
}
type Worker struct {
}
func serveIt(conn io.ReadWriteCloser) {
for {
srv := &scodec{
rw... |
package c24_break_mt19937_stream_cipher
import (
"bytes"
"errors"
"time"
"github.com/vodafon/cryptopals/set1/c1_hex_to_base64"
"github.com/vodafon/cryptopals/set3/c21_mt19937"
)
const (
maxSeed = 65535
tokenSize = 20
)
type prng interface {
ExtractNumber() uint32
}
type ByteStream struct {
rng prng
}
f... |
// Copyright 2023 Google LLC. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applica... |
// A Tour of Go : More types: structs, slices, and maps
// https://go-tour-jp.appspot.com/moretypes/1
package main
import (
"fmt"
"math"
)
func main() {
{
// ポインタ
// C言語とは異なり、ポインタ演算は無い
var i = 10
var p *int = &i
fmt.Println("1-1. ", i, *p, p)
*p = 20
fmt.Println("1-2. ", i, *p, p)
}
{
// 構造体
... |
package main
import (
"log"
"net"
"sync"
"time"
"golang.org/x/net/context"
"google.golang.org/grpc"
pb "github.com/olguncengiz/AppointmentApp/microservice/appointment"
"google.golang.org/grpc/reflection"
)
const (
port = ":50888"
)
// server is used to implement helloworld.GreeterServer.
type server struct{... |
package conv
//go:generate goreify github.com/ElPeque/reflect-db/conv.ToUint uint,uint8,uint16,uint32,uint64,int,int8,int16,int32,int64,float32,float64
func ToUint(elem interface{}) uint {
switch elem.(type) {
case *uint:
return uint(*elem.(*uint))
case *uint8:
return uint(*elem.(*uint8))
case *uint16:
ret... |
// Copyright ©2019 The Gonum 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 product implements graph product functions.
// See https://en.wikipedia.org/wiki/Graph_product for more details.
package product // import "gonum... |
package engine
import (
"time"
units "github.com/docker/go-units"
)
// ServiceInfo of service
type ServiceInfo struct {
Name string `yaml:"name" json:"name" validate:"nonzero"`
Image string `yaml:"image" json:"image" validate:"nonzero"`
Replica int `yaml:"replica" ... |
package tsl
import (
"reflect"
"testing"
"time"
)
func TestQuery_Select(t *testing.T) {
type fields struct {
raw string
}
type args struct {
metric string
}
tests := []struct {
name string
fields fields
args args
want *Query
}{{
name: "plain query",
fields: fields{
raw: "",
},
ar... |
package main
import (
"context"
"fmt"
"log"
"strings"
"time"
"github.com/brigadecore/brigade-foundations/crypto"
"github.com/brigadecore/brigade-foundations/os"
"github.com/brigadecore/brigade/v2/apiserver/internal/api"
"github.com/brigadecore/brigade/v2/apiserver/internal/api/github"
"github.com/brigadecor... |
package main
import (
"fmt"
"html/template"
"log"
"net/http"
"strconv"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
temp, err := template.New("test").Parse(`
{{/*打印参数的值*/}}
Inventory:
SKU: {{.SKU}}
Name: {{.Name}}
UnitPrice: {{.UnitPrice}}
Quantity: {{.... |
package pstats
import (
"io/ioutil"
"os"
"path/filepath"
"strconv"
"strings"
)
//GetRSSInfoLinux ...
func GetRSSInfoLinux() (int64, error) {
pid := os.Getpid()
memPath := filepath.Join("/proc", strconv.Itoa(int(pid)), "statm")
contents, err := ioutil.ReadFile(memPath)
if err != nil {
return 0, err
}
fi... |
package test
import (
"testing"
"fmt"
)
type element struct {
c chan int
}
var m map[string]element
func TestT(t *testing.T) {
ele := element{
c:make(chan int,1),
}
//go func() {
// ele.c <- 1
//}()
select {
case<- ele.c:
fmt.Println("----------")
default:
fmt.Println(",,,,,,,,,")
}
fmt.Println("1... |
package gt2d
import (
"image/color"
)
type Rectangle struct {
Min, Max Vector2D
}
var NullRect Rectangle
// TODO: Add a way to fix the points.
func Rect(x1, y1, x2, y2 int) *Rectangle{
return &(Rectangle{Vector2D{x1, y1}, Vector2D{x2, y2}})
}
func (rectangle *Rectangle) Translate(x, y int) Rectangle {
return ... |
package main
import (
"fmt"
)
var input string = "input.txt"
// count counts the occurence of answers given in a group of persons
func count(g []string) map[rune]int {
m := make(map[rune]int)
for _, p := range g {
for _, a := range p {
m[a] = m[a] + 1
}
}
return m
}
// countAnswersPerGroupAnyone counts ... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/8/14 1:24 下午
# @File : lt_3_最长不重复子串_test.go.go
# @Description :
# @Attention :
*/
package offer
import (
"fmt"
"testing"
)
func Test_lengthOfLongestSubstring(t *testing.T) {
fmt.Println(lengthOfLongestSubstring("abba"))
}
|
package bootstrap
import (
"testing"
"opendev.org/airship/airshipctl/testutil"
)
func TestRemoteDirect(t *testing.T) {
tests := []*testutil.CmdTest{
{
Name: "remotedirect-cmd-with-help",
CmdLine: "remotedirect --help",
Cmd: NewRemoteDirectCommand(nil),
},
}
for _, tt := range tests {
testu... |
package models
type TwitterResponse struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
}
|
package main
import "fmt"
// 插入排序golang实现
func sort(nums []int) []int {
if len(nums) <= 1 {
return nums
}
// 从前往后走
for i := 1; i < len(nums); i++ {
// 取index为i的数字,作为基准值
back := nums[i]
// 遍历index为i之前的数字
j := i - 1
// 这一个循环用于遍历index之前的数组的值
// 如果前面的值比当前Index的值大,那么就需要将前面的值往后移一下
// 直到前面的数字比Index的值小
... |
// Copyright 2015 elliott@tkwcafe.com. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ignore
package beacon
import (
"encoding/hex"
"errors"
"strings"
"github.com/paypal/gatt"
)
func NewServer(name string, manufacturer []by... |
/*
Copyright © 2022 SUSE 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 writing, software
dist... |
package main
import (
"fmt"
"sync"
)
func main() {
flagCount := 0
// 注意:这里不能是空指针
var wg sync.WaitGroup
var lock sync.Mutex
wg.Add(10)
for flagCount < 10 {
go func(wg *sync.WaitGroup, lock *sync.Mutex) {
lock.Lock()
flagCount++
fmt.Printf("waiting for %d year(s)\n", flagCount)
lock.Unlock()
... |
// Copyright 2015 The Hugo Authors. 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 applicable ... |
package main
import (
"fmt"
"net"
)
func main() {
conn,err:=net.Dial("tcp","127.0.0.1:8000")
if err!=nil{
fmt.Println("net.Dail err:",err)
return
}
defer conn.Close()
for {
var msg string
fmt.Println("Send:")
fmt.Scan(&msg)
conn.Write([]byte(msg))
buf := make([]byte, 4096)
n, err ... |
/*
Copyright 2022 The KubeVela 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 exprevaluator is the test package for
// expression evaluator in go programming language
package exprevaluator
// Expr interface represent any expression
type Expr interface {
// Eval returns the value of this Expr in the environment
Eval(env Env) float64
// Check reports errors in this Expr and adds its... |
package distribution
import (
"testing"
)
func TestPools(t *testing.T) {
p := NewPool()
if _, found := p.add("test1"); found {
t.Fatal("Expected pull test1 not to be in progress")
}
if _, found := p.add("test2"); found {
t.Fatal("Expected pull test2 not to be in progress")
}
if _, found := p.add("test1");... |
package mocks
import (
"github.com/globalsign/mgo"
"github.com/urbn/ordernumbergenerator/app"
"github.com/urbn/ordernumbergenerator/app/fixtures"
)
var Error error = nil
type MockSession struct{}
func (ms MockSession) Close() {}
func NewMockSession() MockSession {
return MockSession{}
}
func (ms MockSession) ... |
package blueprint
type Customizations struct {
Hostname *string `json:"hostname,omitempty" toml:"hostname,omitempty"`
Kernel *KernelCustomization `json:"kernel,omitempty" toml:"kernel,omitempty"`
SSHKey []SSHKeyCustomization `json:"sshkey,omitempty" toml:"sshkey,omitempty"`
Use... |
package pathfileops
import "testing"
func TestDirMgr_DeleteAll_01(t *testing.T) {
fh := FileHelper{}
// Set up target directories and files for deletion!
origDir, err := dirMgr01TestCreateCheckFiles03DirFiles()
if err != nil {
t.Errorf("Error returned by dirMgr01TestCreateCheckFiles03DirFiles(). Error='... |
/*
Copyright 2021 CodeNotary, Inc. 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 applicable law or agreed to i... |
package main
import "fmt"
var (
total int /* нийт дүн */
current int /* хэрэглэгчээс өгсөн утга */
counter int /* давталтын тоолуур */
)
func main() {
total = 0
for counter = 0; counter < 5; counter++ {
print("Тоо? ")
fmt.Scanf("%d", ¤t)
total += current
... |
/*
Given a string name, e.g. "Bob", return a greeting of the form "Hello Bob!".
*/
package main
import (
"fmt"
)
func hello_name(s string) string {
if s == "" { return "Hello" }
return "Hello " + s
}
func main(){
var status int = 0
if hello_name("Bob") == "Hello Bob" {
status += 1
}
if hello_name("Alice") =... |
// Main() function
/*
The main() function is a special type of function and it is the entry point of the executable programs.
It does not take any argument nor return anything.
Go automatically call main() function, so there is no need to call main() function explicitly
and every executable program must contain sin... |
package main
import (
"fmt"
"io"
)
func main() {
for {
var number int
_, err := fmt.Scanf("%d", &number)
if err == io.EOF {
break
}
fmt.Print(number)
switch number % 10 {
case 1:
fmt.Println("st")
case 2:
fmt.Println("nd")
case 3:
fmt.Println("rd")
default:
fmt.Println("th")
}
... |
// Package xdserr to load test configuration updates
package xdserr
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
adminv3 "github.com/envoyproxy/go-control-plane/envoy/admin/v3"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/p... |
package kafka
import (
"time"
confluent "github.com/confluentinc/confluent-kafka-go/kafka"
"github.com/etf1/kafka-message-scheduler-admin/server/helper"
"github.com/etf1/kafka-message-scheduler-admin/server/store"
"github.com/etf1/kafka-message-scheduler-admin/server/store/hmap"
"github.com/etf1/kafka-message-s... |
package logger
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"time"
)
// Log represent a log
type Log struct {
Date time.Time
URL string
Data interface{}
}
// LogRequest is a logging middleware to activate with martini. It gets
// request body, date and url
func LogRequest(r *http.Request) ... |
package ds
import (
"time"
)
type Transaction struct {
Id int `json:"-"`
BinId string `json:"bin"`
Filename string `json:"filename"`
Method string `json:"method"`
Path string `json:"path"`
IP string... |
package wasmhttp
import (
"bytes"
"net/http"
"net/http/httptest"
"syscall/js"
promise "github.com/nlepage/go-js-promise"
)
// Request builds and returns the equivalent http.Request
func Request(r js.Value) *http.Request {
jsBody := js.Global().Get("Uint8Array").New(promise.Await(r.Call("arrayBuffer")))
body :... |
package main
import (
"errors"
"fmt"
"io"
"net/http"
"os"
"github.com/Cloud-Foundations/Dominator/lib/fsutil"
"github.com/Cloud-Foundations/Dominator/lib/log"
objectclient "github.com/Cloud-Foundations/Dominator/lib/objectserver/client"
)
func getImageBuildLogSubcommand(args []string, logger log.DebugLogger)... |
package main
import (
"fmt"
"moduledemo/mypackage"
"moduledemo/util"
)
func main() {
fmt.Println("main")
mypackage.Show()
mypackage.UtilShow()
fmt.Println(util.Sum(1, 2, 3, 4))
}
|
package mlapi
import (
"github.com/freignat91/mlearning/mlserver/server"
"golang.org/x/net/context"
)
//ServerLogs .
func (api *MlAPI) ServerLogs() ([]string, error) {
client, _ := api.getClient()
lines, err := client.client.ServerLogs(context.Background(),
&mlserver.ServerLogsRequest{},
)
if err != nil {
r... |
package stringutil
// package stringutil contains utility functions
// for working with package stringutil
// reverse returns argument rune-wise left
func Reverse(s string) string {
r := []rune(s)
for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
r[i], r[j] = r[j], r[i]
}
// string is readonly sli... |
package service
import (
"context"
"fmt"
"io"
"net/http"
pbAS "github.com/go-ocf/cloud/authorization/pb"
"github.com/go-ocf/cloud/cloud2cloud-connector/events"
oapiStore "github.com/go-ocf/cloud/cloud2cloud-connector/store"
"github.com/go-ocf/cloud/cloud2cloud-gateway/store"
kitNetGrpc "github.com/go-ocf/kit... |
// +build !linux
package snapshot
func getSupportsDType(dir string) (bool, error){
return true, nil
}
|
// Separate each 3 digits, e.g. go run main.go 123456.1234567 -> 123'456.123'456'7
package main
import (
"bytes"
"fmt"
"os"
"strconv"
"strings"
)
func main() {
if len(os.Args) != 2 {
fmt.Fprintln(os.Stderr, "please supply a number")
os.Exit(1)
}
number := os.Args[1]
if _, err := strconv.ParseFloat(number... |
// Copyright 2021 BoCloud
//
// 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 wri... |
package main
import (
"github.com/gin-gonic/gin"
"github.com/goboilerplates/micro-websocket/config"
"github.com/goboilerplates/micro-websocket/env"
)
func main() {
env.LoadVariables()
if env.EnableProdMode {
gin.SetMode(gin.ReleaseMode)
}
router := gin.Default()
config.SetMiddleWares(router)
config.SetAP... |
/* Mysterium network payment library.
*
* Copyright (C) 2020 BlockDev AG
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) an... |
//go:build go1.7
// +build go1.7
package rest_test
import (
"bufio"
"bytes"
"errors"
"fmt"
"net/http"
"net/http/httptest"
"strings"
"github.com/kevinburke/rest"
"github.com/kevinburke/rest/restclient"
)
func ExampleRegisterHandler() {
rest.RegisterHandler(500, http.HandlerFunc(func(w http.ResponseWriter, ... |
package nes
import (
"encoding/gob"
"log"
)
type Mapper2 struct {
*Cartridge
prgBanks int
prgBank1 int
prgBank2 int
}
func NewMapper2(cartridge *Cartridge) Mapper {
prgBanks := len(cartridge.PRG) / 0x4000
prgBank1 := 0
prgBank2 := prgBanks - 1
return &Mapper2{cartridge, prgBanks, prgBank1, prgBank2}
}
fun... |
package common
import (
. "framework/api/common/types"
"testing"
)
func TestReadConfig(t *testing.T) {
var cfg LaserConfig
newcfg := ReadConfig(Lasercfg, cfg)
Logging(newcfg)
Logging(cfg)
}
|
package awssqs
import (
"context"
"time"
"github.com/batchcorp/plumber/util"
"github.com/batchcorp/plumber/validate"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/sqs"
"github.com/pkg/errors"
"github.com/batchcorp/plumber-schemas/build/go/protos/opts"
"github.com/batchcorp/plumber-sch... |
package main
import "github.com/mingchoi/LeetCode-Solution/golang/utils"
func main() {
results := append(utils.ParseJavaSolution(), utils.ParseGoSolution()...)
utils.GenerateMarkdownReport(results)
}
|
package task
import (
"context"
"github.com/PhongVX/taskmanagement/internal/pkg/utils/timeutil"
"github.com/globalsign/mgo"
"github.com/globalsign/mgo/bson"
)
func NewMongoDBRepository(session *mgo.Session) *MongoDBRepository {
return &MongoDBRepository{
session: session,
}
}
// Find All task
func (r *Mongo... |
package files
type Files struct {
Name string
Quantity int
}
type Allfiles []Files
|
package tasks
//Task represents a task in the database
type Task struct {
ID int64
Title string
Completed bool
}
|
package loadbalancer_api
type InitPathRequest struct {
PathInfos []PathInfo `json:"pathInfos"`
}
type PathListAll struct {
PathInfos []PathInfo `json:"pathInfos"`
}
|
package handlers
import (
"context"
"github.com/bongnv/gokit/examples/hello"
)
type handlerImpl struct {
}
func (h *handlerImpl) Hello(ctx context.Context, req *hello.Request) (*hello.Response, error) {
return nil, nil
}
func (h *handlerImpl) Bye(ctx context.Context, req *hello.ByeRequest) (*hello.ByeResponse, ... |
/*
Package llsr is a pg_recvlogical wraper for Postgres' Logical Log Streaming Replication.
*/
package llsr
import (
"bytes"
"database/sql"
"strconv"
"github.com/lib/pq/oid"
"github.com/liquidm/llsr/decoderbufs"
)
//Converter is used to conver raw RowMessage structs into app specific data.
type Converter interf... |
// Copyright 2020 Clivern. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package model
import (
"fmt"
"strings"
"time"
"github.com/clivern/walrus/core/driver"
"github.com/clivern/walrus/core/util"
log "github.com/sirupsen/logrus"
"git... |
package main
import "fmt"
func cariWarna(warna string) (hasil string) {
switch {
case warna == "hijau":
hasil = "betul yang dicari"
case warna == "merah":
hasil = "betul yang dicari"
case warna == "biru":
hasil = "betul yang dicari"
default:
hasil = "bukan yang dicari"
}
return
}
func main() {
hasi... |
package server
import (
"testing"
tpb "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/tensor_go_proto"
tspb "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/tensor_shape_go_proto"
dtpb "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/types_go_proto"
)
func TestScalarVal... |
package client
import (
"io"
"io/ioutil"
"net/http"
"net/url"
"github.com/the-forges/sysdigexplorer/errors"
)
// Client encapsulates connection details
type Client struct {
url string
apiKey string
}
// NewClient will give you a *Client with all the required info to make client
// calls to a given sysdig ... |
package services
import (
"encoding/json"
"log"
"net/http"
"github.com/Matias-Barrios/mockyapp/models"
"github.com/Matias-Barrios/mockyapp/network"
)
var (
_requester network.IRequest = network.Request{}
)
type UsersService struct{}
type IUsersService interface {
GetUsers() models.UsersResponse
}
const (
... |
package components
import (
"html/template"
"github.com/GoAdminGroup/go-admin/modules/errors"
"github.com/GoAdminGroup/go-admin/modules/language"
"github.com/GoAdminGroup/go-admin/template/types"
)
type AlertAttribute struct {
Name string
Theme string
Title template.HTML
Content template.HTML
types.A... |
package storage
import (
"context"
"crypto/sha256"
"database/sql"
"errors"
"fmt"
"strings"
"time"
"github.com/google/uuid"
"github.com/jmoiron/sqlx"
"github.com/sirupsen/logrus"
"github.com/authelia/authelia/v4/internal/configuration/schema"
"github.com/authelia/authelia/v4/internal/logging"
"github.com... |
package inmem
import (
"fmt"
graph "github.com/JesseleDuran/gograph"
osm "github.com/JesseleDuran/gograph/osm/pbf"
worker "github.com/JesseleDuran/secure-graph-worker"
"github.com/JesseleDuran/secure-graph-worker/config"
"log"
)
type GraphCreator struct {
S3Manager worker.FileManager
}
func (c GraphCreator) C... |
package main
import (
"fmt"
"github.com/jackytck/projecteuler/tools"
)
func solve(size int) int {
// all the right-angles sitting on the axis
cnt := 3 * size * size
for x := 1; x <= size; x++ {
for y := 1; y <= size; y++ {
f := tools.GCD(x, y)
a := y * f / x
b := (size - x) * f / y
// by mirroring... |
package presenters
import "github.com/ariel17/railgun/api/entities"
// NewDomain is the data used to create a new entry in domain entity.
type NewDomain struct {
URL string `json:"url"`
}
func (nd NewDomain) ToDomain() *entities.Domain {
return &entities.Domain{
URL: nd.URL,
}
} |
package main
import (
"bufio"
"encoding/json"
"fmt"
"os"
"strings"
)
//func for check input string and space character
func trimTrailingCrLf(s string) string {
trimmed := s
if strings.HasSuffix(trimmed, "\n") {
trimmed = strings.TrimSuffix(trimmed, "\n")
}
if strings.HasSuffix(trimmed, "\r") {
trimmed = ... |
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2017 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your opt... |
package service
import "consumer-importer/service/util"
var dbProperties = util.DbProperties{
Host: "localhost",
Port: "5432",
User: "pguser",
Password: "p0stgr3s",
Dbname: "consumer_importer",
}
|
package game
import (
"encoding/json"
"fmt"
"qiniupkg.com/x/errors.v7"
"throne/game/player"
"throne/game/stage"
"throne/game/area"
)
type Player struct {
Game *Game `json:"-"`
CanSet bool
Name string
Money int64
Orders map[player.OrderType]int64 `json:"-"`
PreArea *Area`json:"-"`
}
func Players... |
package problem0139
func wordBreak(s string, wordDict []string) bool {
dp := make([]bool, len(s)+1)
dp[0] = true
for i := 1; i <= len(s); i++ {
for _, word := range wordDict {
start := i - len(word)
if start >= 0 && s[start:i] == word {
dp[i] = dp[i] || dp[start]
}
}
}
return dp[len(s)]
}
|
package nonracecond
import (
"fmt"
"sync"
)
var x = 0
//It is boring to write two similar run functions
//Use struct as excecuted func attribute
type incrAttr struct {
wg *sync.WaitGroup
mx *sync.Mutex
ch chan bool
}
//Increment func increase global variable x by 1
func Increment(input incrAttr) {
switch {
... |
package models
import (
"errors"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
type Location struct {
ID string
Name string
}
func (Location) Get(session *mgo.Session, id string) (location Location, err error) {
collection, err := getCollection(session, MONGO_COL_LOCATION_NAME)
if err != nil {
return locatio... |
package cfmysql
import (
"code.cloudfoundry.org/cli/plugin"
sdkModels "code.cloudfoundry.org/cli/plugin/models"
"fmt"
pluginModels "github.com/andreasf/cf-mysql-plugin/cfmysql/models"
"io"
)
//go:generate counterfeiter . CfService
type CfService interface {
GetStartedApps(cliConnection plugin.CliConnection) ([]... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.