text stringlengths 11 4.05M |
|---|
package kate
import (
"context"
"net/http"
"github.com/k81/kate/log/ctxzap"
"go.uber.org/zap"
)
// Router defines the standard http outer
type Router struct {
*http.ServeMux
maxBodyBytes int64
ctx context.Context
}
// NewRouter create a http router
func NewRouter(ctx context.Context, logger *zap.Log... |
package auth
import (
"context"
"github.com/golang/protobuf/ptypes/empty"
"github.com/caos/zitadel/pkg/grpc/auth"
)
func (s *Server) SearchMyUserGrant(ctx context.Context, in *auth.UserGrantSearchRequest) (*auth.UserGrantSearchResponse, error) {
response, err := s.repo.SearchMyUserGrants(ctx, userGrantSearchReq... |
package function
import (
"bytes"
"encoding/json"
"errors"
"github.com/hecatoncheir/Storage"
"log"
"os"
"text/template"
)
type Storage interface {
Query(string) ([]byte, error)
}
type Executor struct {
Store Storage
}
var ExecutorLogger = log.New(os.Stdout, "Executor: ", log.Lshortfile)
var (
// ErrCateg... |
package main
import (
"io"
"io/ioutil"
"log"
"os"
"os/exec"
"github.com/gin-gonic/gin"
)
func index_get(ctx *gin.Context) {
cmd := exec.Command("ls")
result, _ := cmd.Output()
ctx.HTML(200, "index.html", string(result))
}
func index_post(ctx *gin.Context) {
file, _ := ctx.FormFile("file")
file_content, _... |
// Copyright 2019 Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in complian... |
package core
import "fmt"
func Hello() {
fmt.Println("Hello n64emu!")
}
|
// Copyright (c) 2017-2018 Zededa, Inc.
// SPDX-License-Identifier: Apache-2.0
// Manage Xen guest domains based on the subscribed collection of DomainConfig
// and publish the result in a collection of DomainStatus structs.
// We run a separate go routine for each domU to be able to boot and halt
// them concurrently... |
package balancer
// Smooth weighted round-robin balancing
// Ref: https://github.com/phusion/nginx/commit/27e94984486058d73157038f7950a0a36ecc6e35
type swrr struct {
items []*Choice
count int
}
func NewSmoothWeightedRoundRobin(choices ...*Choice) (lb *swrr) {
lb = &swrr{}
lb.Update(choices)
return
}
func (b *sw... |
package main
import (
// 系统包
"database/sql"
"fmt"
// 自定义包
"github.com/qiulc/gotest/conn/myredis"
"github.com/qiulc/gotest/conn/mysql"
// 外包
"github.com/go-redis/redis"
)
var db *sql.DB
var rdb *redis.Client
func main() {
fmt.Println("你好啊 ")
var err error
db, err = mysql.InitDB()
if err != nil {
fmt.P... |
//go:generate go get github.com/UnnoTed/fileb0x
//go:generate fileb0x b0x.yml
//go:generate go get -v github.com/jteeuwen/go-bindata/...
//go:generate go get -v github.com/elazarl/go-bindata-assetfs/...
//go:generate go-bindata -nomemcopy -prefix builtin_models/ -pkg caffe -o builtin_models_static.go -ignore=.DS_Store... |
package gopaxos
import (
"github.com/buptmiao/gopaxos/paxospb"
)
type systemVariableStore struct {
logStorage LogStorage
}
func newSystemVariableStore(ls LogStorage) *systemVariableStore {
return &systemVariableStore{
logStorage: ls,
}
}
func (s *systemVariableStore) write(wo WriteOptions, groupIdx int, sysVa... |
package models
import (
"time"
)
// album represents data about a record album.
type Request struct {
ID int `json:"id"`
ServiceId int `json:"service_id"`
ResponseTime float32 `json:"response_time"`
CreatedAt time.Time `json:"created_at"`
}
type RequestList struct {
Requests []Request `json:"requ... |
package main
import (
"fmt"
"sync"
)
func main() {
sizes := make(chan int)
var wg sync.WaitGroup
nums := 10
for num := 0; num < nums; num++ {
wg.Add(1)
go func(num int) {
defer wg.Done()
sizes <- num
}(num)
}
go func() {
wg.Wait()
close(sizes)
}()
for rt := range sizes {
fmt.Println(rt)
... |
package main
// https://www.domoticz.com/forum/viewtopic.php?t=1785 // virtual device?
// https://www.domoticz.com/forum/viewtopic.php?t=10940 // sonos
// https://github.com/jishi/node-sonos-http-api // sonos api
// https://www.domoticz.com/forum/viewtopic.php?t=11577 // update virtual device
// https://github.com/dhl... |
package golang
func FindSmallestNum(arr []int) int {
smallestNum := arr[0]
smallestNumIndex := 0
for i := 1; i < len(arr); i++ {
if arr[i] < smallestNum {
smallestNum = arr[i]
smallestNumIndex = i
}
}
return smallestNumIndex
}
func SelectSort(arr []int) []int{
newArr := make([]int, 0, len(arr))
for l... |
// Copyright 2014 Wandoujia Inc. All Rights Reserved.
// Licensed under the MIT (MIT-LICENSE.txt) license.
package cmd
import (
"bufio"
"log"
"sync"
"time"
)
import (
"github.com/wandoulabs/codis/ext/redis-port/utils"
)
func Dump(ncpu int, from, output string) {
log.Printf("[ncpu=%d] dump from '%s' to '%s'\n"... |
package renderer
import (
"bytes"
"image"
"image/color"
"image/draw"
"github.com/driusan/de/demodel"
"github.com/driusan/de/renderer"
"golang.org/x/image/font"
"golang.org/x/image/math/fixed"
)
// The default renderer. Performs no syntax highlighting.
type NoSyntaxRenderer struct {
renderer.DefaultSizeCalce... |
package model
type Todo struct {
ID string `json:"id"`
Text string `json:"text"`
UID string `json:"uid"`
}
|
package utils_test
import (
. "github.com/gin-tonic/pkg/api/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Utils unit tests", func() {
Describe("Read config file", func() {
Context("With specified config file path", func() {
It("should exist and can be marshalled", func() ... |
package miner
import (
"btcnetwork/common"
"encoding/hex"
)
type MiningState uint32
const (
StateStop = MiningState(0)
StateOneBlock = MiningState(1)
StateAuto = MiningState(2)
)
type Config struct {
Version uint32
Target [32]byte
Bits uint32
//区块容量上限
//区块奖励
Reward uint64
MinerPubKe... |
// 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 ion
import (
"bytes"
"errors"
"fmt"
"io"
"math/big"
"reflect"
"strconv"
"strings"
)
var (
// ErrNoInput is returned when there is no input to decode
ErrNoInput = errors.New("ion: no input to decode")
)
// Unmarshal unmarshals Ion data to the given object.
func Unmarshal(data []byte, v interface{}) ... |
// Copyright 2022 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 main
import (
"fmt"
)
/*
Задача 4. Три числа: еще попытка
Напишите программу, которая запрашивает у пользователя три числа и выводит количество чисел, которые больше, либо равны 5.
*/
func main() {
var total, examScore int
cntNumber := 3
contolNumber := 5
arr := make([]int, cntNumber)
fmt.Println("Пр... |
package wechat
import "time"
type Config struct {
AppID string `json:"appid"`
SecretKey string `json:"secret_key"`
Timeout int `json:"timeout"`
}
func (cfg *Config) TimeoutDuration() time.Duration {
timeout := cfg.Timeout
if timeout == 0 {
timeout = 30
}
return time.Duration(timeout) * time.Second... |
package http
import (
"log"
"strings"
)
// HTTP请求结构体,包含HTTP方法,版本,URI,HTTP头,内容长
type Request struct {
//http 请求方法
method http_method
//http 版本
version http_version
//原始方法
method_raw string
//原始版本
version_raw string
uri string
port int
headers *http_headers
content_length int
//数据... |
package main
import "github.com/vferko/golang-brno/db"
type Todo struct {
Id int
Description string
IsDone bool
}
func GetAll() []Todo {
db := db.GetDB()
rows, err := db.Query("SELECT * FROM")
if err != nil {
panic(err)
}
defer rows.Close()
var todoList []Todo
for rows.Next() {
todo := ... |
// 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 dlp
import (
"context"
"net/http"
"net/http/httptest"
"net/url"
"time"
"chromiumos/tast/common/fixture"
"chromiumos/tast/common/policy/fakedms"
"chromiumos/... |
package solutions
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
type ListNode struct {
Val int
Next *ListNode
}
func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {
l1Next := l1
l2Next := l2
head := &ListNode{}
originalHead := head
va... |
// Copyright (c) 2018-present, MultiVAC Foundation.
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
package wire
import (
"encoding/gob"
"io"
"github.com/multivactech/MultiVAC/model/chaincfg/multivacaddress"
"github.com/multivactech/Mu... |
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package login
import (
"context"
"time"
"unicode/utf8"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/chrom... |
package auth
import (
"../models"
"../repos/session"
"../repos/user"
)
// Auth interface for something that make basic auth functions
type Auth interface {
Init(ur user.Repo, sr session.Repo) error
Login(login string, pass string) (*models.Session, error)
Logout(id string) error
CheckSession(id string) (*mod... |
package main
import (
"github.com/cloudfoundry/buildpacks-ci/tasks/cnb/helpers"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
)
func UpdateOrders(orders []helpers.Order, dep helpers.Dependency) []helpers.Order {
for i, order := range orders {
for j, group := range order.Group {
if group.ID == d... |
package main
import (
"math"
"math/rand"
)
//给定圆的半径和圆心的 x、y 坐标,写一个在圆中产生均匀随机点的函数 randPoint 。
//
//说明:
//
//输入值和输出值都将是浮点数。
//圆的半径和圆心的 x、y 坐标将作为参数传递给类的构造函数。
//圆周上的点也认为是在圆中。
//randPoint 返回一个包含随机点的x坐标和y坐标的大小为2的数组。
//示例 1:
//
//输入:
//["Solution","randPoint","randPoint","randPoint"]
//[[1,0,0],[],[],[]]
//输出: [null,[-0.72... |
// Copyright 2021 Comcast Cable Communications Management, 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 ... |
package service
import (
"bytes"
"encoding/json"
"fmt"
login "github.com/carprks/login/service"
permissions "github.com/carprks/permissions/service"
"io/ioutil"
"net/http"
"os"
"time"
)
// LoginObject ...
type LoginObject struct {
Identifier string `json:"identifier"`
Permissions []permi... |
package remote
import (
"fmt"
"strings"
)
// TagImpl TagImpl
type TagImpl struct {
Value string `json:"value"`
}
// GetName Name
func (s *TagImpl) GetName() (ret string) {
items := strings.Split(s.Value, " ")
ret = items[0]
return
}
// IsPrimaryKey IsPrimaryKey
func (s *TagImpl) IsPrimaryKey() (ret bool) {
... |
/*++
Copyright (C) 2018 Autodesk Inc. (Original Author)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of condition... |
package main
import (
"fmt"
"math"
)
func exported_names() {
fmt.Println("[exported_names.go]", math.Pi)
}
|
package main
import (
"bytes"
"compress/gzip"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/url"
"time"
"wishCollection/models"
"wishCollection/utility"
)
var stop bool
var runing bool
var collectionTime time.Duration
func init() {
collectionTime = time.Minute * 2
}
func main() {
go re... |
package structs
type HealthStatus int
const (
Down HealthStatus = iota - 1
Unhealthy
Healthy
)
type Health struct {
Modules []ModuleHealth `json:"modules"`
}
type ModuleHealth struct {
ModuleName string `json:"module_name"`
Status HealthStatus `json:"status"`
StatusCode int `json:"status_co... |
package main
import (
"bufio"
"errors"
"fmt"
"io"
"unicode"
)
type Parser struct {
w io.Writer
r *bufio.Reader
lookahead rune
}
func NewParser(w io.Writer, r io.Reader) *Parser {
return &Parser{
w: w,
r: bufio.NewReader(r),
}
}
func (p *Parser) Parse() error {
if err := p.next(); err ... |
/*
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 sharedobj
import (
"github.com/cyberark/secretless-broker/pkg/secretless/log"
"github.com/cyberark/secretless-broker/pkg/secretless/plugin"
"github.com/cyberark/secretless-broker/pkg/secretless/plugin/connector/http"
"github.com/cyberark/secretless-broker/pkg/secretless/plugin/connector/tcp"
)
const plugi... |
package checkifbst
import (
"golangexercises/binarytrees/fillfromarray"
"sort"
"testing"
)
func TestBST(t *testing.T) {
intArray := []int{2, 15, 3, 4, 5, 11, 6, 7, 9, 8, 10, 12, 1, 13, 14}
bstRoot1 := fillfromarray.CreateTree(intArray)
if IsBST(bstRoot1) {
t.Errorf("Not a BST\n")
}
sort.Ints(intArray)
bs... |
/*
Copyright (c) 2014
Dario Brandes
Thies Johannsen
Paul Kröger
Sergej Mann
Roman Naumann
Sebastian Thobe
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code mu... |
/*
Go client for Intuit's Customer Account Data API
*/
package intuit
import (
"encoding/xml"
"fmt"
"github.com/MattNewberry/oauth"
"time"
)
const (
InstitutionXMLNS = "http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1"
ChallengeXMLNS = "http://schema.intuit.com/platform/fdatafeed/challenge/v1"
... |
package gwfunc
import (
assert2 "github.com/stretchr/testify/assert"
"testing"
"time"
)
func TestExec_Normal(t *testing.T) {
var f = func() {
time.Sleep(1 * time.Second)
}
ok := Timeout(f, 5*time.Second)
assert2.False(t, ok)
}
func TestExec_Timeout(t *testing.T) {
var f = func() {
time.Sleep(5 * time.Sec... |
/*
*Copyright (c) 2019-2021, Alibaba Group Holding Limited;
*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 ... |
package timer
type TimerManager interface {
GetTimerTasks(blockHeight int64) (uint64, error)
}
|
//
// 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 requesttotree
import (
"encoding/json"
"log"
"reflect"
)
// NewTree function return new empty tree.
func NewTree() *Tree {
return &Tree{}
}
// NewEmptyNode function return new empty node
// it can be either root node or normal node.
func NewEmptyNode(root bool) *Node {
if root {
return &Node{
name:... |
/*
* Created on Mon Jan 13 2020 10:17:54
* Author: WuLC
* EMail: liangchaowu5@gmail.com
*/
/*
* Created on Mon Jan 13 2020 10:17:54
* Author: WuLC
* EMail: liangchaowu5@gmail.com
*/
func makeConnected(n int, connections [][]int) int {
if len(connections) < n - 1 {
return -1
}
graph := make(map[int][]int... |
// noinspection GoStructTag
package test_select
// goDao: generate
// language=PostgreSQL
type GoDao struct {
Add func(a, b int64) (int64, error) `
select ($1::int8 + $2::int8)::int8 as sum;`
}
//go:generate go run ../..
|
package token
import "cointhink/db"
import "cointhink/proto"
import "log"
func FindByAccountId(accountId string, algorunId string) (*proto.Token, error) {
log.Printf("token.FindByAccount accountId %+v algorunId %+v", accountId, algorunId)
item := &proto.Token{}
err := db.D.Handle.Get(item,
"select "+Columns+" fr... |
package Week_03
import (
"fmt"
"testing"
)
var res = make([][]int, 0)
func permute(nums []int) [][]int {
r := []int{}
backtrack(nums, r)
return res
}
func backtrack(nums []int, r []int) {
if len(r) == len(nums) {
res = append(res, r)
return
}
for i := 0; i < len(nums); i++ {
if inSlice(r, nums[i]) {
... |
package ravendb
import (
"errors"
"fmt"
"reflect"
)
// TODO: cleanup, possibly rethink entityToJSON
type entityToJSON struct {
session *InMemoryDocumentSessionOperations
missingDictionary map[interface{}]map[string]interface{}
//private final Map<Object, Map<string, Object>> _missingDictionary = new ... |
// SPDX-License-Identifier: MIT
package openapi
import "github.com/caixw/apidoc/v7/core"
// 数据验证接口
type sanitizer interface {
Sanitize() *core.Error
}
|
package main
import (
"fmt"
"net/http"
"os"
"github.com/porter-dev/porter/internal/config"
)
func main() {
appConf := config.FromEnv()
resp, err := http.Get(fmt.Sprintf("http://localhost:%d/api/livez", appConf.Server.Port))
if err != nil || resp.StatusCode >= http.StatusBadRequest {
os.Exit(1)
}
resp, ... |
package internal
import (
"log"
"os"
"path/filepath"
)
func Install(curdir, home string) {
index, err := OpenIndex(curdir)
if err != nil {
log.Fatal(err)
}
for _, file := range index.ListFiles() {
path := index.Get(file)
err := os.MkdirAll(filepath.Join(home, filepath.Dir(path)), os.ModePerm)
if err !=... |
package manager
import (
"testing"
"github.com/xuperchain/xupercore/kernel/contract"
_ "github.com/xuperchain/xupercore/kernel/contract/kernel"
"github.com/xuperchain/xupercore/kernel/contract/mock"
"github.com/xuperchain/xupercore/kernel/contract/sandbox"
)
var contractConfig = &contract.ContractConfig{
Xkern... |
package main
func main() {
var p []int
print(p)
}
|
package services
import (
"log"
"models"
"github.com/gosimple/slug"
"github.com/microcosm-cc/bluemonday"
"models/status"
"strings"
"config"
"path/filepath"
"utils"
"repository"
"controllers/viewmodels"
"fmt"
"github.com/dustin/go-humanize"
"strconv"
)
type ArticleService struct {
repo *repository.Repo... |
// 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, ... |
// ------------------------------------------------------ {COPYRIGHT-TOP} ---
// Licensed Materials - Property of IBM
// 5900-AEO
//
// Copyright IBM Corp. 2020, 2021. All Rights Reserved.
//
// US Government Users Restricted Rights - Use, duplication, or
// disclosure restricted by GSA ADP Schedule Contract with IBM C... |
package logs
import (
"github.com/sirupsen/logrus"
)
//Logger based logger struct
type Logger struct {
*logrus.Logger
}
//Get returns the logger instance with specified parameters
func Get(level string) *Logger {
var logger Logger
ll := logrus.New()
ll.SetLevel(getLogLevel(level))
ll.SetReportCaller(true)
log... |
package main
import (
"fmt"
)
func isCancelled(threshold int, timings []int) bool {
count := 0
for _, v := range timings {
if v <= 0 {
count++
}
}
return count < threshold
}
func main() {
scores := []int{-1, -3, 4, 2}
fmt.Println(isCancelled(3, scores))
}
|
package model
type Body struct {
Package string
Struct string
Alias string
}
|
// description : Echoing the program arguments
// author : Tom Geudens (https://github.com/tomgeudens/)
// modified : 2016/06/26
//
package main
import(
"fmt"
"os"
)
func main() {
s, sep := "", ""
for _, arg := range os.Args[1:] {
s += sep + arg
sep = " "
}
fmt.Println(s)
}
|
package model
type List []*Interval
func (list List) Len() int {
return len(list)
}
func (list List) Less(i, j int) bool {
return list[i].Before(list[j])
}
func (list List) Swap(i, j int) {
list[i], list[j] = list[j], list[i]
}
|
package grpc
import (
"context"
"encoding/json"
"github.com/gogo/protobuf/jsonpb"
"github.com/gogo/protobuf/proto"
"github.com/iancoleman/strcase"
)
//Parse request proto message to model
func Parse(ctx context.Context, request interface{}, model interface{}) (interface{}, error) {
protoMessage := request.(pro... |
// 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 2016 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 rpm currently serves no purpose other than to namespace the rpm/spec
package.
In the future, this package may hold functions and structs for working with RPM
packages directly, but for now, it is nothing more than a placeholder.
*/
package rpm
|
/*
* Lean tool - hypothesis testing application
*
* https://github.com/MikaelLazarev/willie/
* Copyright (c) 2020. Mikhail Lazarev
*
*/
package helpers
import (
"bytes"
"encoding/json"
"errors"
"fmt"
errors2 "github.com/MikaelLazarev/willie/server/errors"
"io/ioutil"
"log"
"net"
"net/http"
"time"
)
t... |
package engine
import (
"log"
)
type ConcurrentEngine struct {
Scheduler Scheduler
WorkerCount int
}
type Scheduler interface {
Submit(Request)
ConfigureMasterWorkerChan(chan Request)
// WorkerReady(chan Request)
// Run()
}
func (e *ConcurrentEngine)Run(seeds ...Request){
in :=make(chan Request)
out :=make(c... |
package main
import (
"database/sql"
"github.com/99designs/gqlgen/handler"
"github.com/deslee/gqlgen_todos"
"github.com/deslee/gqlgen_todos/database"
_ "github.com/mattn/go-sqlite3"
"log"
"net/http"
"os"
)
const defaultPort = "8080"
func main() {
db, err := sql.Open("sqlite3", "file:database.db")
if err !=... |
package fluvio
type Record struct {
Offset int64
Key []byte
Value []byte
}
|
package cosmwasm
import (
"encoding/json"
"fmt"
"github.com/CosmWasm/go-cosmwasm/api"
"github.com/CosmWasm/go-cosmwasm/types"
)
// CodeID represents an ID for a given wasm code blob, must be generated from this library
type CodeID []byte
// WasmCode is an alias for raw bytes of the wasm compiled code
type WasmC... |
package typeutils
import (
"encoding/json"
"fmt"
"testing"
"github.com/stretchr/testify/suite"
)
// These tests demonstrates and validates use of a Registry to marshal/unmarshal JSON.
type JsonTestSuite struct {
suite.Suite
film *filmJson
}
var testRegistryJson = NewRegistry()
func init() {
if err := testR... |
// osdconfig is a package to work with distributed config parameters
package osdconfig
// A config manager interface allows management of osdconfig parameters
// It defines setters, getters and callback management functions
type ConfigManager interface {
// GetClusterConf fetches cluster configuration data from a bac... |
//go:build !windows
// +build !windows
package fleetyaml
import (
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
)
func TestBundleYaml(t *testing.T) {
a := assert.New(t)
for _, path := range []string{"/foo", "foo", "/foo/", "foo/", "../foo/bar"} {
// Test both the primary extension and the f... |
// Package encoding defines interfaces shared by other packages that are used by
// usrv servers and clients to encode and decode the endpoint-specific request
// and response messages into a byte-level format suitable for transmitting over
// a transport.
package encoding
// Marshaler is the interface implemented by ... |
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
//
package model
const (
execMMCTL = "mmctl"
execMattermostCLI = "mattermost"
)
// IsValidExecCommand returns wheather the provided command is valid or not.
func IsValidExecCommand(command string... |
package main
//Invalid
//To check if bool is okay to use or not as an expression statemnet
func main() {
true;
}
|
package gen
import (
"fmt"
"github.com/felixangell/goof/ast"
"github.com/felixangell/goof/cc/unit"
"github.com/felixangell/goof/types"
"io"
"os"
"os/exec"
"reflect"
"strconv"
)
// TODO:
// there are some inconsistencies
// in generation where we should convert
// to the weird IR abstraction for
// easier gen... |
package main
import (
"bytes"
"fmt"
"math"
"net/smtp"
"path/filepath"
"strconv"
"strings"
"text/tabwriter"
)
func SendMail(from string, to string, cc string, pwd string, title string, msg string) error {
header := ""
header += "From:" + from + "\n"
header += "To:" + to + "\n"
header += "Cc:" + cc + "\n"
... |
/*
* Copyright 2020 Kaiserpfalz EDV-Service, Roland T. Lichti.
*
* 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 ... |
/*
* Copyright (C) 2018 eeonevision
*
* 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, modify, merge, publish... |
package main
import (
"fmt"
"io/ioutil"
"log"
"path/filepath"
"github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/rpcclient"
"github.com/btcsuite/btcutil"
)
//default:
//"sb1qg6ydpvdx8hhdrtvfs46zx0wx049nyht8xjn7zr",
/... |
// Copyright (c) KwanJunWen
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
package estemplate
import "fmt"
// DatatypeFlattened Specialised Datatype that allows an entire JSON object
// to be indexed as a single field. This data type can ... |
package util
const (
prefix = "harvesterhci.io"
RemovedPVCsAnnotationKey = prefix + "/removedPersistentVolumeClaims"
AnnotationMigrationTarget = prefix + "/migrationTargetNodeName"
AnnotationMigrationUID = prefix + "/migrationUID"
AnnotationMigrationState = prefix ... |
package lib_gc_conf
import (
"fmt"
"os"
"strings"
)
func init() {
//flag.StringVar(&CONF_PREFIX, "loaderConfigMisc", ".", "Is necessary to spcify the application configuration directory: -loaderConfigMisc ./myconf")
//flag.Parse()
setLoaderConf()
}
var Dummy struct{}
var CONF_PREFIX string = ""
const CONF_PR... |
package sensor
import "time"
//type properties struct {
// ValueType string `json:"value_type"`
// Value string `json:"value"`
//}
//type sensorReads struct {
// SensorID string `json:"esp8266id"`
// SensorData []properties `json:"sensordatavalues"`
//}
// Record single measurement record
type Record st... |
package main
import (
"errors"
"fmt"
"log"
)
func main() {
r, err := doError()
if err != nil {
log.Printf("There was an error: %v\n", err)
}
fmt.Println("My message:", r)
r, _ = doNoError()
fmt.Println(r)
err = moreError()
if err != nil {
log.Println(err)
}
}
func doError() (string, error) {
retu... |
package client
import (
"context"
"crypto/tls"
"errors"
"log"
"net"
"net/http"
"regexp"
"strconv"
"time"
"golang.org/x/oauth2"
"golang.org/x/oauth2/clientcredentials"
)
const (
defaultHTTPTimeout = 10 * time.Second
)
var (
ErrInvalidDNSResolver = errors.New("invalid DNS resolver specified. Requi... |
package service
import (
"github.com/bioxeed/momenton-challenge/db"
"github.com/sirupsen/logrus"
)
// EmployeeService provides methods to work with Employees
type EmployeeService interface {
// List returns all employee records
List() ([]Employee, error)
}
type employeeService struct {
log logrus.FieldLogger
... |
package main
import (
"fmt"
"strings"
)
func bomberman(seconds int, grid []string) (output []string) {
if seconds < 2 {
output = grid
} else if seconds%2 == 0 {
var row string = strings.Repeat("O", len(grid[0]))
for i := 0; i < len(grid); i++ {
output = append(output, row)
}
} else {
nGrid := [][]in... |
package main
import (
"github.com/gorilla/mux"
"log"
"net/http"
)
type middleWareHandler struct {
r *mux.Router
l *ConnLimiter
}
func (m middleWareHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if !m.l.GetConn() {
w.WriteHeader(http.StatusTooManyRequests)
w.Write([]byte("Too many request"))
... |
package algorun
func Owns(algologId string, accountId string) bool {
log, err := Find(algologId)
if err != nil {
return false
} else {
return log.AccountId == accountId
}
return false
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.