text stringlengths 11 4.05M |
|---|
package middlewares
type DefaultMiddleware struct {
}
|
package pkg2
import "fmt"
func Demo2() {
fmt.Println("demo2")
}
func init() {
fmt.Println("init2")
}
|
package registrar
import (
"log"
"github.com/pivotal-cf/on-demand-service-broker/cf"
"github.com/pivotal-cf/on-demand-service-broker/config"
"github.com/pkg/errors"
)
type RegisterBrokerRunner struct {
Config config.RegisterBrokerErrandConfig
CFClient RegisterBrokerCFClient
Logger *log.Logger
}
//go:gene... |
package resiver
import (
"errors"
"sync"
)
type Manager struct {
mu sync.RWMutex
resivers map[string]*ResiversRuntime
}
func (m *Manager) Add(resiver *Resiver) error {
if _, ok := m.resivers[resiver.Name()]; !ok {
return errors.New("Resiver is already exist")
}
m.mu.Lock()
m.resivers[resiver.Name()]... |
package handlers
import (
"github.com/hashicorp/go-hclog"
"github.com/jinzhu/gorm"
"github.com/milutindzunic/pac-backend/data"
"github.com/milutindzunic/pac-backend/database"
"net/http"
)
type DBInitHandler struct {
db *gorm.DB
logger hclog.Logger
eventStore data.EventStore
l... |
// Copyright © 2016 Prometheus Team
//
// 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 tests
import (
"github.com/ravendb/ravendb-go-client"
"github.com/stretchr/testify/assert"
"testing"
)
func getDatabaseRecordCanGetDatabaseRecord(t *testing.T, driver *RavenTestDriver) {
var err error
store := driver.getDocumentStoreMust(t)
defer store.Close()
op := ravendb.NewGetDatabaseRecordOperati... |
// Copyright 2021 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 app
import (
"MF/hamsoyamodels"
"MF/helperfunc"
"MF/models"
"MF/settings"
"MF/token"
"encoding/json"
"fmt"
"github.com/julienschmidt/httprouter"
"io/ioutil"
"log"
"math"
"net/http"
"strconv"
"time"
)
//Handler for login // Get log and pass
func (server *MainServer) LoginHandler(writer http.Respo... |
package main
import("fmt"
"net/http"
"log"
"strings)
type cocktails struct {}
func drinks(w http.ResponseWriter, req * http.Request) {
id := strings.TrimPrefix(req.URL.Path, "/provisions/")
//will be for name cocktails
name := strings.TrimPrefix(req... |
/*
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... |
package function
import (
"encoding/json"
"math/rand"
"net/http"
"time"
)
// PasswordSpec is function body reference
type PasswordSpec struct {
Length int `json:"length,omitempty"`
UpperCaseNum int `json:"upper_case_num,omitempty"`
DigitNum int `json:"digit_num,omitempty"`
SpecialCharNum int `... |
// Copyright 2019 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... |
//This file contains code for node info and user info
//@author Devansh Gupta
//facebook.com/devansh42
//github.com/devansh42
package utils
import "strings"
type NodeInfo struct {
Name string
Email string
Contact string
Domain string
Id int64
Pubkey string
}
//Map for userinfo tree
type UserInfo ma... |
package resample_test
import (
"fmt"
"github.com/paulmach/orb"
"github.com/paulmach/orb/planar"
"github.com/paulmach/orb/resample"
)
func ExampleResample() {
ls := orb.LineString{
{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0},
{5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}, {10, 0},
}
// downsample in this case so ther... |
package pipelineconfig
import (
"log"
"alauda.io/devops-apiserver/pkg/apis/devops/v1alpha1"
devopsclient "alauda.io/devops-apiserver/pkg/client/clientset/versioned"
)
// RenderJenkinsfile render jenkinsfile
func RenderJenkinsfile(client devopsclient.Interface, namespace string, spec *PipelineConfigDetail) (jenkin... |
package main
import (
"fmt"
"io/ioutil"
"os"
"testing"
"github.com/exercism/cli/configuration"
"github.com/stretchr/testify/assert"
)
func assertFileDoesNotExist(t *testing.T, filename string) {
_, err := os.Stat(filename)
if err == nil {
t.Errorf("File [%s] already exist.", filename)
}
}
func TestLogou... |
//https://tour.golang.org/moretypes/2
//here are structs, simmiliar to the classes we are used to in ruby. However structs have been a thing for a while, theyre a core datatype in C.
//https://flaviocopes.com/golang-is-go-object-oriented/
package main
import "fmt"
type position struct{ //declaration syntax will tak... |
package api_test
import (
"net/http"
"net/http/httptest"
"strings"
"time"
"github.com/go-chi/chi"
"github.com/porter-dev/porter/internal/config"
"github.com/porter-dev/porter/internal/helm"
"github.com/porter-dev/porter/internal/kubernetes"
lr "github.com/porter-dev/porter/internal/logger"
"github.com/porte... |
// 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 delta
import (
"github.com/coreos/go-systemd/sdjournal"
"log"
)
var LogChannel = "logstream"
func (dc *DeltaCore) StartLogStreamEngine() {
j, err := sdjournal.NewJournal()
if err != nil {
log.Println(err)
return
}
err = j.SeekTail()
if err != nil {
log.Println(err)
return
}
for {
n, _ := ... |
// SPDX-License-Identifier: MIT
package lsp
import (
"io/ioutil"
"log"
"path/filepath"
"testing"
"github.com/issue9/assert/v3"
"github.com/caixw/apidoc/v7/core"
"github.com/caixw/apidoc/v7/core/messagetest"
"github.com/caixw/apidoc/v7/internal/ast"
"github.com/caixw/apidoc/v7/internal/lsp/protocol"
"githu... |
// Copyright (c) 2018 The MATRIX Authors
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php
package p2p
import (
"encoding/json"
"math/big"
"sync"
"time"
"github.com/MatrixAINetwork/go-matrix/ca"
"github.com/MatrixAINetwork/g... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
type response struct {
Message string `json:"message,omitempty"`
}
func main() {
port := 3000
host := "0.0.0.0"
http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
writer.Header().Set("Content-Type", "ap... |
package mysql
import "reflect"
const (
TagDB = "db" // 数据库内字段名称
TagMajor = "major" // 主键
)
type Tag struct {
DB string
Major string
}
func NewTag(tag reflect.StructTag) *Tag {
return &Tag{
DB: tag.Get(TagDB),
Major: tag.Get(TagMajor),
}
}
|
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
strfmt "github.com/go-openapi/strfmt"
... |
package main
import (
"fmt"
"math"
)
// todo
// 别人的答案
// 奇数长度和偶数长度
// 左右指针从中间向两端,回文类问题;别的左右指针从两端向中间
func longestPalindrome(s string) string {
l := math.MinInt
res := ""
for i := 0; i < len(s); i++ {
v := longestPalindromeInNK(s, i, i)
v1 := longestPalindromeInNK(s, i, i+1)
if len(v) > l {
res = v
// ... |
package main
import (
"errors"
"fmt"
"time"
)
// User struct your colleague is implementing this
type User struct {
ID string
Name string
Email string
}
func (u User) GetUserDetails(id string) (User, error) {
if id != ""{
return User{
ID: id,
Name: "Miikka",
}, nil
}
return User{}, errors.New("no ... |
// 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... |
package iqiyiv2
import (
"errors"
"fmt"
"regexp"
"strconv"
"strings"
"time"
"videocrawler/clients"
"videocrawler/common/util"
"videocrawler/crawler"
"videocrawler/crawler/iqiyi"
"github.com/buger/jsonparser"
"github.com/fatih/color"
)
type Iqiyi2 struct {
*iqiyi.IqiyiT
}
func (this *Iqiyi2) GetVideoIn... |
package util
import (
"github.com/devspace-cloud/devspace/pkg/devspace/config/versions/util"
"github.com/devspace-cloud/devspace/pkg/util/kubeconfig"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
)
fun... |
package main
import (
"fmt"
"io/ioutil"
"os"
"path"
"sync"
// bytesize "github.com/inhies/go-bytesize"
)
func du(filepath string, fileSize chan<- int64, n *sync.WaitGroup) {
defer n.Done()
for _, file := range readDir(filepath) {
if file.IsDir() {
n.Add(1)
go du(path.Join(filepath, file.Name()), fileS... |
package main
import (
"time"
"net/http"
"encoding/json"
)
type Routes struct {
staticDir string
apiKey string
apiSecret string
}
// Route: Data
type Data struct {
Query string `json:"query"`
Datetime string `json:"datetime"`
}
// /api/data
func (r Routes) apiDataRoute(resp http.ResponseWr... |
package main
import "encoding/json"
type Result map[string]map[string][]string
func (r Result) Add(f *Footprint) {
if _, ok := r[f.Hash]; ok == false {
r[f.Hash] = make(map[string][]string)
r[f.Hash][f.Title] = []string{}
}
r[f.Hash][f.Title] = append(r[f.Hash][f.Title], f.Url)
}
func process(c <-chan *Footp... |
package main
// Leetcode 739. (medium)
func dailyTemperatures(T []int) []int {
res := make([]int, len(T))
stack := make([]int, 1)
stack[0] = 0
for i := 1; i < len(T); i++ {
for len(stack) > 0 && T[stack[len(stack)-1]] < T[i] {
res[stack[len(stack)-1]] = i - stack[len(stack)-1]
stack = stack[:len(stack)-1]
... |
package main
import "testing"
func TestXxx(t *testing.T) {
a := NewAuthor()
id, name := NewAuthorIDs()
if a.ID != id {
t.Error("Expected author ID to be `whoami` but was nil")
}
if a.Name != name {
t.Error("Expected author name to be 'Your Name' but was ", a.Name)
}
if a.URL != "https://author.example.com... |
package basic
import "testing"
func TestEmployment(t *testing.T) {
employment := AccountabilityType(1)
company := Organization{}
smith := Person{}
period := TimePeriod{}
// companyはsmithに対して雇用(employment)の責任関係を持つ
t.Log(Accountability{employment, period, &Party(company), &Party(smith)})
}
func TestManager(t *t... |
package odoo
import (
"fmt"
)
// HrDepartment represents hr.department model.
type HrDepartment struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
AbsenceOfToday *Int `xmlrpc:"absence_of_today,omptempty"`
Active *Bool `xmlrpc:"active,omptempty"`
Al... |
package main
import "strings"
func main() {
// var a = 13
// var b uint = 15
println(len(`"hello
dddddd
go!"`))
println(strings.Compare("b", "c"))
}
|
package zap_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/shanexu/logn/common"
"github.com/shanexu/logn/core/zap"
_ "github.com/shanexu/logn/includes"
)
func TestNew(t *testing.T) {
rawConfig, err := common.NewConfigFrom(`
appenders:
console:
- name: CONSOLE
target: stdo... |
package gitlabClient
import (
"github.com/xanzy/go-gitlab"
)
func (git *GitLab) ListGroup() ([]*gitlab.Group, error) {
opt := &gitlab.ListGroupsOptions{
ListOptions: gitlab.ListOptions{
PerPage: 100,
Page: 1,
},
}
for {
// Get the first page with projects.
groups, resp, err := git.Client.Groups.... |
package shell
import (
"yunion.io/x/onecloud/pkg/multicloud/jdcloud"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
func init() {
type DescribeMetricDataOptions struct {
/* 监控项英文标识(id) */
Metric string `help:"metric name"json:"metric"`
TimeInterval string `help:"time interval" choices:"1h|6h|12h|1d|3d|7... |
/*
1 fizzbuzz.go
Output the numbers from 1 to 100, one per line. However, if the number is divisible by 3 output 'Fizz', if the number is divisible output 'Buzz' and if the number is divisible by both 3 and 5 output 'FizzBuzz'
Author: tatu.kairi@gmail.com
*/
package main
import (
"fmt"
"strconv"
)
func main() {
... |
package model
// LightMeasuredPayload is a Schema defined in the AsyncAPI specification
// TODO: Support custom tags
type LightMeasuredPayload struct {
// Lumens is a property defined in the AsyncAPI specification
Lumens *int64 `json:"lumens"`
// SentAt is a property defined in the AsyncAPI specification
... |
package main
import "fmt"
func main() {
var n int
fmt.Scan(&n)
arr := make([]int, n)
for i := range arr {
fmt.Scan(&arr[i])
}
sorted := insertionSort(arr)
// printArray(sorted)
}
func insertionSort(arr []int) []int {
var x, j int
shiftsNumber := 0
for i := 1; i < len(arr); i++ {
x = arr[i]
j = i
... |
package migrations
import (
"github.com/Focinfi/sakura/app/models"
"github.com/Focinfi/sakura/db"
)
func init() {
migrate(
&models.User{},
&models.ActivityNote{},
&models.Tag{},
&models.ActivityNoteTag{},
&models.ActivityCategory{},
&models.ActivityNoteCategory{},
&models.Feeling{},
&models.UserFee... |
package persistent
import (
"fmt"
"github.com/EventStore/EventStore-Client-Go/position"
"github.com/EventStore/EventStore-Client-Go/protos/persistent"
"github.com/EventStore/EventStore-Client-Go/protos/shared"
)
func updateRequestStreamProto(config SubscriptionStreamConfig) *persistent.UpdateReq {
return &persi... |
package customsearch
type (
apiKey string
)
func (a apiKey) Get() (string, string) {
return "key", string(a)
}
|
package main
import (
"context"
"fmt"
)
type User struct {
Name string
IsLoggedIn bool
}
type userKeyType int
var userKey userKeyType
func contextWithUser(ctx context.Context, user *User) context.Context {
return context.WithValue(ctx, userKey, user)
}
func getUserFromContext(ctx context.Context) *User... |
package main
// Microservice
// Test Handler
// Copyright © 2016 Eduard Sesigin. All rights reserved. Contacts: <claygod@yandex.ru>
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestHandlerHelloWorld(t *testing.T) {
req, _ := http.NewRequest("GET", "/", nil)
w := httptest.NewRecorder()
conf, err := ... |
/*
Copyright © 2021 Damien Coraboeuf <damien.coraboeuf@nemerosa.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modi... |
// Copyright 2018 The go-Dacchain Authors
// This file is part of the go-Dacchain library.
//
// The go-Dacchain library 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... |
package chart
import (
"fmt"
"github.com/go-echarts/go-echarts/v2/charts"
"github.com/go-echarts/go-echarts/v2/opts"
// "github.com/go-echarts/go-echarts/v2/types"
)
//多重柱状图
func BarMulti(table *Table) *charts.Bar {
bar := charts.NewBar()
bar.SetGlobalOptions(
charts.WithTitleOpts(opts.Title{
Title: ... |
package main
import (
"fmt"
"encoding/json"
//"reflect"
)
type Book struct {
Title string
Author string
Pages int
}
// JSON.Marshal(): Takes Struct and returns a byte array.
func (b Book) ToJSON() []byte { // No need to pass object as method is attached to Book struct anyway.
byte_array, err :=... |
package organization
type Invitation struct {
Created Date `json:"created"`
Role string `json:"role"`
User string `json:"user"`
}
|
// Package testhelper provides some useful helpers for testing in github.com/768bit/promethium/lib/images/diskfs subpackages
package testhelper
|
package game
import (
"encoding/csv"
"fmt"
"io"
"strings"
)
type Game struct {
Grid1, Grid2 Grid
Move1, Move2 Moves
M, S, T int
// private fields
p1score, p2score int
p1ShipCount, p2ShipCount int
}
type Move struct {
X, Y int
}
type Moves []Move
// populate is a unexported function which p... |
package util
type Comparable interface {
Equal(Comparable) bool
}
func IsStringSliceEqual(arr1 []string, arr2 []string) bool {
if len(arr1) == len(arr2) {
var i int
var c1, c2 string
for i, c1 = range arr1 {
c2 = arr2[i]
if c1 != c2 {
return false
}
}
return true
} else {
return false
}
}... |
package main
import (
"context"
"fmt"
"time"
"github.com/mongodb/mongo-go-driver/mongo"
"github.com/mongodb/mongo-go-driver/mongo/options"
)
//时间点
type TimePoint struct {
StartTime int64 `bson:"starttime"`
EndTime int64 `bson:"endtime"`
}
//日志结构
type LogRecord struct {
JobName string `bson:"jobname"`... |
// Copyright (C) 2018-Present Pivotal Software, Inc. All rights reserved.
// This program and the accompanying materials are made available under the terms of the 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 Licen... |
//
// June 2016, cisco
//
// Copyright (c) 2016 by cisco Systems, Inc.
// All rights reserved.
//
//
package main
import (
"github.com/dlintw/goconf"
"testing"
"time"
)
func TestMetricsConfigureNegative(t *testing.T) {
var nc nodeConfig
mod := metricsOutputModuleNew()
cfg, err := goconf.ReadConfigFile("pipel... |
package requirements
import "fmt"
import "math"
/**
Calculate a triangle area based on Heron's formula:
Area = √p(p−a)(p−b)(p−c)
where p = (a + b + c) / 2
*/
func getTriangleArea(len1 int, len2 int, len3 int) float64 {
if !isValidTriangle(len1, len2, len3) {
panic(fmt.Sprintf("InvalidTriangleException"))
}
var ... |
package pushserver
import (
"BakatoraPushServer/src/pushserver/db"
"BakatoraPushServer/src/rabbitmq"
"BakatoraPushServer/src/util"
"encoding/json"
"errors"
"fmt"
"github.com/gin-gonic/gin"
"github.com/go-netty/go-netty"
"log"
"strconv"
"sync"
)
type Producer struct {
ServerName string
Exchange *rabbitm... |
// Copyright (C) 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed t... |
/*
Copyright The containerd 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... |
package services
import (
"fmt"
"net"
"net/http"
"net/http/pprof"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
type Pprof struct {
host string
port int
ln net.Listener
}
const (
pprofHostFlag = "pprof-host"
pprofPortFlag = "pprof-port"
)
func RegisterPprofFlags(f... |
package main
import (
"fmt"
)
func countBits(num int) []int {
res := make([]int, num+1)
for i := 1; i <= num; i = i + 1 {
if i&1 == 0 {
res[i] = res[i/2]
} else {
res[i] = res[i/2] + 1
}
}
return res
}
func main() {
input := 5
fmt.Println(countBits(input))
}
|
package orchestra
import (
//"fmt"
"github.com/aws/aws-sdk-go/aws/session"
)
func CreateSession() (*session.Session, error) {
sess, err := session.NewSession()
if err != nil {
return nil, err
}
if _, err := sess.Config.Credentials.Get(); err != nil {
return nil, err
}
return sess, nil
}
|
package symlink
import "os"
// Replace will replace existing symlink
func Replace(filePath string, symlinkPath string) error {
return replaceSymlink(filePath, symlinkPath)
}
// Delete will remove symlink
func Delete(symlinkPath string) error {
return deleteSymlink(symlinkPath)
}
// Exists check symlink is exists ... |
package ranges
import "github.com/adamluzsi/frameless/ports/iterators"
func Int(begin, end int) iterators.Iterator[int] {
return &intRange{Begin: begin, End: end}
}
type intRange struct {
Begin, End int
nextIndex int
closed bool
}
func (ir *intRange) Close() error {
ir.closed = true
return nil
}
func (i... |
package main
import (
"flag"
"fmt"
"io"
"net/http"
"sync"
"time"
)
var sess_cookie http.Cookie
var resp string
type ConnectionCount struct {
mu sync.Mutex
cur_conn int
max_conn int
total_conn int
}
var scoreboard ConnectionCount
func (cc *ConnectionCount) open() {
cc.... |
package sa
import "github.com/jinzhu/gorm"
type (
Shop struct {
Shop_Id int `json:"shop_id"`
Address_id int `json:"address_id"`
Size int `json:"size"`
Workers int `json:"workers"`
}
Address struct {
gorm.Model
City string `json:"city"`
Street string `json:"street"`
Number string `json... |
package main
import (
"sync"
"errors"
pb "../protobuf/go"
"container/list"
"github.com/op/go-logging"
)
type AccountState struct {
lock sync.RWMutex
data map[string]int32
}
func (self *AccountState) add(key string, value int32) (int32, error) {
self.lock.Lock()
defer self.lock.Unlock()
return self.add_nosy... |
package config
import (
"github.com/kelseyhightower/envconfig"
"go.uber.org/zap"
)
// Config - server configuration structure
type Config struct {
Env string `envconfig:"ENV" default:"development"`
Port int `envconfig:"PORT" default:"8080"`
DBHost string `envconfig:"DB_HOST"`
DBPort int `envconfig:"DB_P... |
// 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 inventory
import (
"github.com/astaxie/beego/orm"
)
// ProductCategories holds information about erp products
type ProductCategories struct {
// Common fields
ID int `orm:"auto;column(ID)"`
Title string `orm:"size(100);column(Title)"`
}
// TableName specifies actual name of table in database
func (... |
// Copyright 2018 cloudy itcloudy@qq.com. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package tools
import (
"fmt"
"github.com/pkg/errors"
"github.com/spf13/viper"
"os"
"os/exec"
"strconv"
"strings"
)
// IntToStr converts integer... |
// +build integration
package repository_test
import (
"context"
"fmt"
"io/ioutil"
"testing"
"gopkg.in/mgo.v2/bson"
"gopkg.in/mgo.v2"
"github.com/darren-west/app/user-service/models"
"github.com/darren-west/app/user-service/repository/testutils/container"
"github.com/darren-west/app/user-service/reposito... |
package utils
import (
"fmt"
"io"
"math/big"
"github.com/zhaohaijun/matrixchain/common"
"github.com/zhaohaijun/matrixchain/common/serialization"
"github.com/zhaohaijun/matrixchain/vm/neovm/types"
)
func WriteVarUint(w io.Writer, value uint64) error {
if err := serialization.WriteVarBytes(w, types.BigIntToByte... |
package main
import (
"context"
"flag"
"fmt"
"github.com/zacharychang/go-study/grpc/proto/echo"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"io"
"log"
"net"
"os"
)
var (
port = flag.Int("port", 1200, "the port to listen")
)
type server struct{}
func (s *server... |
package main
import (
"net/http"
"strconv"
"io/ioutil"
"encoding/json"
"log"
)
// This variable hold in memory storage
// It seems that go doesn't support thread global variable
// Have to get around it using a hack. Use dictionary to store data for each http service
var in_memory_storage map[string][]KeyValueCo... |
package store
import (
"testing"
"time"
)
func TestParameter(t *testing.T) {
// t.Run("New Parameter", func(t *testing.T) {
// p := NewParameter("foo", nil)
// if p == nil {
// t.Fatalf("Unable to create a new parameter")
// }
// if fmt.Sprintf("%T", p) != "*store.Parameter" {
// t.Fatalf("Returned ... |
package moxings
type Yinpinshanchujius struct {
Id int
Xuliehao string `gorm:"not null;DEFAULT:0"`
Yishanchu int64 `gorm:"not null;DEFAULT:0"`
Shanchubiaoji int64 `gorm:"not null;DEFAULT:0"`
}
func (Yinpinshanchujius) TableName() string {
return "Yinpinshanchujius"
}
|
/*
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... |
/*****************************************************************************
* file name : MemPool.go
* author : Wu Yinghao
* email : wyh817@gmail.com
*
* file description : 内存池
*
******************************************************************************/
package SparrowCache
import (
"fmt"
"time"
... |
// Copyright 2020 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package camera
import (
"context"
"time"
"chromiumos/tast/common/media/caps"
"chromiumos/tast/remote/bundles/cros/camera/camerabox"
"chromiumos/tast/remote/bundles/cro... |
package main
import "fmt"
//map 数据类型
func main() {
//两种定义方式
//第一个string 是那种数据类型,第二个string 是返回值类型,可以换成结构体,后面会学到
//var mymap map[string]string
// //
// //fmt.Println(mymap)
// //
// //var mymaps= make(map[string]string)
// //mymaps["tim"]="gogos"
// //mymaps["zs"]="zsdf"
// //fmt.Println(mymaps)
//几种定义方式
//... |
package api
import (
"github.com/pkg/errors"
"github.com/ssok8s/ssok8s/pkg/api/dtos"
"github.com/ssok8s/ssok8s/pkg/bus"
"github.com/ssok8s/ssok8s/pkg/components/simplejson"
m "github.com/ssok8s/ssok8s/pkg/models"
"regexp"
)
func createSrp(c *m.ReqContext, form dtos.CreateSrpForm) Response {
//todo check namesp... |
// Copyright 2020 The LUCI 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... |
package storageos
import (
storagev1beta1 "k8s.io/api/storage/v1beta1"
kdiscovery "k8s.io/client-go/discovery"
"github.com/storageos/cluster-operator/internal/pkg/discovery"
k8sresource "github.com/storageos/cluster-operator/pkg/util/k8s/resource"
)
// createCSIDriver creates a StorageOS CSIDriver resource with ... |
package db
import (
"github.com/truebluejason/p2e-background/internal/conf"
_ "github.com/go-sql-driver/mysql"
"database/sql"
)
type Content struct {
Id int
Type string
Author string
Payload string
}
var dataSource string = conf.Configs.DBUser + ":" + conf.Configs.DBPassword + "@tcp(" + conf.Configs.DBHost + ... |
// Copyright 2019 Ulisse Mini. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"bufio"
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
log "github.com/UlisseMini/leetlog"
"github.com/go-yaml/yaml"
"githu... |
/**
* @Author: DollarKiller
* @Description: Config
* @Github: https://github.com/dollarkillerx
* @Date: Create in 11:37 2019-10-24
*/
package config
import (
"github.com/dollarkillerx/easyutils"
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
"time"
)
type base struct {
App struct {
Host string `yaml:"host"`... |
package users
import (
"fmt"
"math"
"net/http"
"net/http/httptest"
"net/url"
"strconv"
"strings"
"sync"
"testing"
"github.com/google/uuid"
"github.com/jrapoport/gothic/core/context"
"github.com/jrapoport/gothic/hosts/rest"
"github.com/jrapoport/gothic/models/types"
"github.com/jrapoport/gothic/models/ty... |
package leetcode
func findSubstringInWraproundString(p string) int {
var count [26]int
var length int
for i := 0; i < len(p); i++ {
if 0 < i && (p[i-1]+1 == p[i] || p[i-1] == p[i]+25) {
length++
} else {
length = 1
}
b := p[i] - 'a'
count[b] = max(count[b], length)
}
var ans int
for i := 0; i ... |
package shell
import (
"github.com/redhat-openshift-ecosystem/openshift-preflight/certification"
log "github.com/sirupsen/logrus"
)
type OperatorPkgNameIsUniqueCheck struct{}
func (p *OperatorPkgNameIsUniqueCheck) Validate(imgRef certification.ImageReference) (bool, error) {
mounted := true
result, err := podman... |
package model
import "sync"
type Loginer interface {
Vaild() error
GetServer() (interface{} ,error)
}
type CommonLoginParam struct {
Package int `json:"package" form:"package"`
Channel string `json:"channel" form:"channel"`
UserId string `json:"userId" form:"userId"`
Account string `json:"account"`
}
var Serv... |
package main
import (
"bank.explorer/service/icbc"
"bank.explorer/util/dates"
"bank.explorer/common"
"strconv"
"bank.explorer/model"
"bank.explorer/config"
"bank.explorer/exception"
"bank.explorer/service"
)
func main() {
service.ConfigInit()
defer exception.Handle(true)
id ,_ := strconv.Atoi(config.Job... |
package main
import (
"bufio"
"bytes"
"crypto/md5"
"io"
"math"
"os"
"sort"
"strconv"
"strings"
"time"
)
const (
// Number of records will reside in buffer memory until the next flush
BufferedRecordsLimit = 20
// Number of records log file can sustain
LogFileRecordLimit = BufferedRecordsLimit * 10
// ... |
package hello
import (
"github.com/gin-gonic/gin"
"github.com/go-conflict/toolkit"
"net/http"
)
func sayHello(c *gin.Context) {
toolkit.SetJson(c, http.StatusOK, "hello go-conflict", nil)
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.