text stringlengths 11 4.05M |
|---|
package httpsign
import (
"context"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const (
sampleBodyContent = "hello world"
)
func newAuthorizationHeader(s string) http.Header {
return http.Header{
`Authorization`: []string{s},
}
}
func newSignatureHead... |
package cache
import (
"bytes"
"errors"
"fmt"
"reflect"
"strconv"
"strings"
"sync"
blk "github.com/DynamoGraph/block"
"github.com/DynamoGraph/db"
"github.com/DynamoGraph/ds"
param "github.com/DynamoGraph/dygparam"
slog "github.com/DynamoGraph/syslog"
"github.com/DynamoGraph/types"
"github.com/DynamoGrap... |
/*
Copyright © 2020 Thomas Mitchell
*/
//Package cmd defines actions to be run from the command line.
package cmd
import (
"fmt"
"os"
"sync"
"time"
"github.com/cloudfoundry-community/merge-bosh-dns/cmd/internal"
"github.com/cloudfoundry-community/merge-bosh-dns/merge"
"github.com/spf13/cobra"
)
// serverCmd... |
package conf
import (
"encoding/json"
"log"
)
type NetConfig struct {
CniVersion string `json:"CniVersion"`
Name string `json:"name"`
Check bool `json:"disableCheck"`
// Plugins []Plugin `json:"plugins"`
Plugin
}
type Plugin struct {
Type string `json:"myBridge"`
Bridge string `json:"bri... |
package main
import "fmt"
type ListNode struct {
Val int
Next *ListNode
}
func main() {
head := ListNode{4, &ListNode{5, &ListNode{6, &ListNode{7, &ListNode{8, nil}}}}}
printList(oddEvenList(&head))
}
func printList(l *ListNode) {
for l != nil {
fmt.Printf("%+v %p\n", l, l)
l = l.Next
}
}
func oddEvenLi... |
package main
import "fmt"
type okc1 int
type okc2 func(int, string) int
func (o okc1) show() {
fmt.Println("相当于Python的setter")
}
type Person struct {
name string
age int
}
func (p Person) show() {
fmt.Printf("姓名:%v 年龄:%v\n", p.name, p.age)
}
// 需要使用 *Person 指针类型,否则无法修改
func (p *Person) setAge(age int) {
p.a... |
package fizzbuzz
import (
"fmt"
)
// Fizzbuzz accepts an Int and returns the appropriate FizzBuzz Test compliant string
func Fizzbuzz(i int) string {
var result string
if i%3 == 0 {
result += "Fizz"
}
if i%5 == 0 {
result += "Buzz"
}
if len(result) == 0 {
result = fmt.Sprintf("%v", i)
}
return result
}... |
// Copyright (c) 2019-2020 IrineSistiana
//
// 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, pub... |
package common
import (
"crypto/sha256"
"fmt"
"git.dustess.com/mk-base/util/crypto"
"strings"
)
// Encrypt 加密密码
func Encrypt(pwd string) string {
salt := crypto.RandID()
return salt + "." + Sha256([]byte(salt+pwd))
}
// Verify 校验密码 `pwd` 是不是明文 `plaintext` 的密码
func Verify(plaintext, pwd string) bool {
s := str... |
package main
import (
"fmt"
"io.Reader"
"strings"
"os"
)
type alphaReader struct{
reader io.Reader
}
func NewAlphaReader(reader io.Reader) *alphaReader{
return &(alphaReader{reader: reader})
}
func alpha(char byte) byte{
if(char >= 'a' && char <= 'z' || char >= 'A' && char <= 'Z'){
return char
}
retur... |
// Copyright 2016-2017 The psh Authors. All rights reserved.
package psh
import "testing"
func TestSegmentUsernameCompile(t *testing.T) {
expected := `\u`
segment := NewSegmentUsername()
segment.Compile()
if string(segment.Data) != expected {
t.Fatalf("Compiled data expected to be %q but got %q", expected, stri... |
package advent
import (
"bufio"
"fmt"
"os"
"unicode"
)
func day5() error {
i, err := os.Open("day5.input")
if err != nil {
return err
}
defer i.Close()
var text string
scanner := bufio.NewScanner(i)
for scanner.Scan() {
text += scanner.Text()
}
if err := scanner.Err(); err != nil {
return err
}
... |
package ibmcloud
import (
"errors"
"fmt"
"testing"
"github.com/IBM/go-sdk-core/v5/core"
"github.com/IBM/networking-go-sdk/dnsrecordsv1"
"github.com/IBM/platform-services-go-sdk/resourcemanagerv2"
"github.com/IBM/vpc-go-sdk/vpcv1"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
metav1 "k... |
package main
/*
@Time : 2020/8/9 17:31
@Author : DELL ricemarch@foxmail.com
@tips: https://leetcode-cn.com/problems/search-a-2d-matrix-ii/comments/
*/
func searchMatrix(matrix [][]int, target int) bool {
if matrix == nil || len(matrix) == 0 {
return false
}
shorterDim := Min(len(matrix), len(matrix[0]))
for i ... |
package main
import "testing"
func TestTemperatureSensor_Get(t *testing.T) {
type fields struct {
Estimator Estimator
temperature int
}
tests := []struct {
name string
fields fields
want int
}{
name: "When Temperature sensor is created",
want: 0,
}
for _, tt := range tests {
t.Run(tt.name,... |
package service
import (
"context"
"errors"
"git.dustess.com/mk-base/util/crypto"
"git.dustess.com/mk-training/mk-blog-svc/pkg/common"
"git.dustess.com/mk-training/mk-blog-svc/pkg/user/dao"
"git.dustess.com/mk-training/mk-blog-svc/pkg/user/model"
"time"
)
var (
password = errors.New("密码或用户名不正确")
)
// userSe... |
package security
import (
"strconv"
"strings"
"time"
"cloud.google.com/go/datastore"
"github.com/google/uuid"
)
type GaeSession struct {
ip string
personUUID string
firstName string
lastName string
email string
created *time.Time
expiry *time.Time
authenticate... |
package lib_test
import (
"encoding/json"
"strings"
"github.com/ayoul3/phishkiller/lib"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
type jsonData struct {
Param1 string
Ip string
}
var _ = Describe("PrepareData", func() {
Describe("When data is JSON", func() {
It("should return proper hea... |
package ds
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
func NewTreeNode(value int, left *TreeNode, right *TreeNode) *TreeNode {
treenode := new(TreeNode)
treenode.Val = value
treenode.Left = left
treenode.Right = right
return treenode
}
func (treenode *TreeNode) Find(val int) bool {
... |
package main
import (
"fmt"
"os"
"strings"
"time"
"github.com/common-nighthawk/go-figure"
)
func exit() int {
return 0
}
func main() {
myFigure := figure.NewFigure("goPassGen", "big", true)
myFigure.Print()
fmt.Println(" [bigb0ss]")
fmt.Println("")
fmt.... |
// Encode image from local path to base64.
package main
import (
"encoding/base64"
"fmt"
"io/ioutil"
)
func main() {
bytes, err := ioutil.ReadFile("")
if err != nil {
fmt.Println("main.ReadFile,", err)
}
fmt.Println(base64.URLEncoding.EncodeToString(bytes))
} |
package main
import (
"flag"
"log"
"os"
"os/signal"
"strings"
"sync"
"syscall"
)
func main() {
// Parse command line
var (
dnsType string
gdnsCertFile string
)
flag.StringVar(&dnsType, "dns-type", "google", "What DNS provider")
flag.StringVar(&gdnsCertFile, "google-credentials", "", "Google cred... |
package game_map
import (
"fmt"
"github.com/faiface/pixel/pixelgl"
"github.com/steelx/go-rpg-cgm/animation"
"github.com/steelx/go-rpg-cgm/state_machine"
"reflect"
)
type CSRunAnim struct {
Name string
Character *Character
CombatState *CombatState
Entity *Entity
Anim animation.Animation
... |
package secrets
import (
"errors"
"fmt"
"testing"
"github.com/10gen/realm-cli/internal/cloud/realm"
"github.com/10gen/realm-cli/internal/utils/test/assert"
"github.com/10gen/realm-cli/internal/utils/test/mock"
)
func TestSecretInputResolve(t *testing.T) {
testLen := 7
secrets := make([]realm.Secret, testLen)... |
package leetcode
import (
"testing"
)
func Test_addTwoNum(t *testing.T) {
l1 := createLinkList([]int{1,3,5,8,5})
l2 := createLinkList([]int{1,3,5,8})
res := addTwoNumbers(l1, l2)
t.Log(showLinkList(res))
}
|
package api
import (
"bytes"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"time"
"github.com/shreddedbacon/fronius-client/fronius"
)
// FakePowerwall holds the value for the inverter host that will get passed to the fronius client
type FakePowerwall struct {
Inverter string
Inver... |
package main
import (
"fmt"
"strings"
)
//闭包相当于 "类", 类中方法和变量的操作即构成一个环境--"闭包"
//闭包使用演示
func makeSuffix(suffix string) func(name string) string {
return func(name string) string {
//如果 传入文件没有后缀,则给拼接后缀
if !strings.HasSuffix(name, suffix) {
return name + suffix
}
//有后缀,则直接返回
return name
}
}
func main() ... |
package rpc
import (
"context"
"github.com/sirupsen/logrus"
"github.com/txze/visitorpb/go"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"visitor/client/redis_client"
"visitor/pkg/visitor_persistence"
)
func (s *Service) AddVisitor(ctx context.Context, req *visitorpb.AddVisitorRequest) (*vis... |
package monitors
import (
"time"
"github.com/jungju/circle_manager/_example/beegoapp/models"
"github.com/jungju/circle_manager/_example/beegoapp/synchronization"
"github.com/jungju/circle_manager/modules"
"github.com/sirupsen/logrus"
)
func RunSendNotification() {
t := time.NewTicker(60 * time.Second)
defer t... |
package latest
import (
"github.com/devspace-cloud/devspace/pkg/devspace/config/versions/config"
"github.com/devspace-cloud/devspace/pkg/util/log"
)
// Upgrade upgrades the config
func (c *Config) Upgrade(log log.Logger) (config.Config, error) {
panic("unimplemented")
}
// UpgradeVarPaths upgrades the config
func... |
package netutil_test
import (
"net"
"testing"
"github.com/AdguardTeam/golibs/netutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestSubnetSet_optimized(t *testing.T) {
t.Parallel()
spPurpSet := netutil.SubnetSetFunc(netutil.IsSpecialPurpose)
locSrvSet := netutil.Subne... |
package media
// Sample contains media, and the amount of samples in it
type Sample struct {
Data []byte
Samples uint32
}
|
// Copyright 2019-2023 The sakuracloud_exporter 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 appl... |
package common
import (
"fmt"
"os"
)
type ExitAwareError interface {
error
ExitStatus() int
}
func HandleError(err error) error {
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
switch err.(type) {
case ExitAwareError:
os.Exit(err.(ExitAwareError).ExitStatus())
}
}
return err
}
|
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//303. Range Sum Query - Immutable
//Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.
//Example:
/... |
package main
func main() {
// addN := func(m int) {
// return func(n int) {
// return m + n
// }
// }
// add5 := addN(5)
}
|
package main
import (
"context"
"github.com/Pallinder/go-randomdata"
)
type Feature struct {
Name string `json:"feature"`
Value string `json:"value"`
}
type Sale struct {
ProductGroup string `json:"product_group"`
Product string `json:"product"`
Brand string `json:"brand"`
Price ... |
package main
import (
"database/sql"
"fmt"
"log"
"encoding/json"
"net/http"
"strconv"
"github.com/gorilla/mux"
"github.com/gorilla/handlers"
_ "github.com/lib/pq"
)
type App struct {
Router *mux.Router
DB *sql.DB
}
// Creates the database connection and establishes routes
func (a *App) Init... |
package main
import (
"dms/command"
"fmt"
"github.com/urfave/cli"
"os"
)
// GitCommitHash git commit hash value
var GitCommitHash = ""
// VersionSuffix suffix version
var VersionSuffix = ""
func main() {
app := buildApp()
err := app.Run(os.Args)
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
}
... |
package pin_client
import (
"context"
api "github.com/aibotsoft/gen/pinapi"
"github.com/aibotsoft/micro/config"
"go.uber.org/zap"
)
type Client struct {
cfg *config.Config
log *zap.SugaredLogger
*api.APIClient
}
func (c *Client) GetCurrencies(ctx context.Context) ([]api.Currency, error) {
resp, _, err := c.O... |
package RegularExpressions
import (
"dsm/NFA"
"fmt"
)
type Operation interface {
fmt.Stringer
Precedence() int
ToNFADesign(stateIterator *StateIterator) NFA.NFADesign
}
func Bracket(operation Operation, outerPrecedence int) string {
if operation.Precedence() < outerPrecedence {
return "(" + operation.String(... |
package core
import (
"fmt"
"strings"
)
type Endpoint struct {
From Currency `json:"from"`
To Currency `json:"to"`
Exchange Exchange `json:"exchange"`
Orderbook *Orderbook `json:"orderbook"`
}
type EndpointLookup struct {
Endpoint *Endpoint
PathsCount int
}
func (e Endpoint) display() {... |
package export
const (
// 日期格式
TimeFormat = "2006/01/02 15:04:05"
)
|
// Copyright 2019 Kuei-chun Chen. All rights reserved.
package mdb
import (
"context"
"encoding/json"
"os"
"testing"
"time"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/mongo/driver/connstring"
)
var colle... |
package intercom
import "testing"
func TestFindConversation(t *testing.T) {
conversationService := ConversationService{Repository: TestConversationAPI{t: t}}
convo, _ := conversationService.Find("123")
if convo.ID != "123" {
t.Errorf("Did not receive conversation")
}
}
func TestReadConversation(t *testing.T) {... |
package config
import (
"fmt"
"io/ioutil"
yaml "gopkg.in/yaml.v2"
)
// Config top-level structure
type Config struct {
Storage *StorageConfig `yaml:"storage"`
Webserver *WebserverConfig `yaml:"webserver"`
Projects *ProjectsConfig `yaml:"projects"`
}
func (c *Config) validate() error {
if c.Storage == ... |
/*
Copyright (C) 2018 Intel Corporation.
SPDX-License-Identifier: Apache-2.0
*/
package oimcommon
import (
"strings"
"github.com/pkg/errors"
)
const (
// RegistryAddress is the special registry path element for the gRPC target value.
RegistryAddress = "address"
// RegistryPCI is the special registry path ele... |
package main
import (
"log"
"net/http"
"os"
"github.com/building-microservices-with-go/chapter4/data"
"github.com/building-microservices-with-go/chapter4/handlers"
)
func main() {
serverURI := "localhost"
if os.Getenv("DOCKER_IP") != "" {
serverURI = os.Getenv("DOCKER_IP")
}
store, err := data.NewMongoSt... |
package bank
import (
sdk "github.com/ColorPlatform/color-sdk/types"
)
// expected crisis keeper
type CrisisKeeper interface {
RegisterRoute(moduleName, route string, invar sdk.Invariant)
}
|
package postgres
import (
"context"
"strings"
"github.com/neuronlabs/errors"
"github.com/neuronlabs/neuron-core/query"
"github.com/neuronlabs/neuron-postgres/filters"
"github.com/neuronlabs/neuron-postgres/internal"
"github.com/neuronlabs/neuron-postgres/log"
"github.com/neuronlabs/neuron-postgres/migrate"
)... |
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package sample
// [START using_namespaces_with_the_Task_Queue]
import (
"io"
"net/http"
"golang.org/x/net/context"
"google.golang.org/appengine"
"google.... |
package pong
import (
"fmt"
"math/rand"
"github.com/gabrielEscame/go-engine/engine"
"github.com/gabrielEscame/go-engine/physics"
"github.com/veandco/go-sdl2/sdl"
)
type Ball struct {
x float64
y float64
radius float64
dirX float64
dirY float64
}
func (b *Ball) Update(i *engine.Input, dt floa... |
package matcher
import (
"context"
"encoding/json"
"log"
"strings"
"github.com/coreos/etcd/clientv3"
"github.com/rudeigerc/broker-gateway/mapper"
"github.com/rudeigerc/broker-gateway/model"
"github.com/rudeigerc/broker-gateway/service"
"github.com/satori/go.uuid"
"github.com/shopspring/decimal"
"github.com... |
package iigointernal
import (
"fmt"
"github.com/SOMAS2020/SOMAS2020/internal/common/config"
"github.com/SOMAS2020/SOMAS2020/internal/common/gamestate"
"github.com/SOMAS2020/SOMAS2020/internal/common/roles"
"github.com/SOMAS2020/SOMAS2020/internal/common/rules"
"github.com/SOMAS2020/SOMAS2020/internal/common/sha... |
// Copyright (c) 2016, Ben Morgan. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
package dist
import (
"fmt"
"math/rand"
)
// Stairs returns the index of the first probability value that exceeds the
// random value between 0.0 and 1.0.
//
//... |
package seatgeekLayer
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"otherside/api/redisLayer"
"reflect"
"time"
)
//SeatGeekEvent is a struct to handle pertinent SeatGeek response data.
type SeatGeekEvent struct {
Title string
EventType string
URL string
Performers []... |
package main
import (
"crypto/hmac"
"crypto/sha1"
"encoding/base64"
"flag"
"strconv"
//"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"time"
)
var appid = flag.String("appid", "", "the appid")
var privkey = flag.String("privkey", "", "the privkey")
var areaids = flag.String("areaids", "", "t... |
// Copyright 2021 PingCAP, 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 to i... |
package area
import (
"server"
. "server/data/datatype"
"server/libs/log"
)
type Scene struct {
server.Callee
}
func (s *Scene) OnAfterAdd(self Entity, sender Entity, index int) int {
log.LogMessage("scene add obj", sender.ObjectId(), index)
self.FindExtraData("cell").(*cell).AddObject(sender)
return 1
}
fun... |
// Copyright 2022 PingCAP, 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 to i... |
package controllers
import (
"math/rand"
"net/smtp"
"festi.io/database"
"festi.io/models"
"github.com/gofiber/fiber/v2"
"golang.org/x/crypto/bcrypt"
)
func Forgot(c *fiber.Ctx) error {
var data map[string]string
if err := c.BodyParser(&data); err != nil {
return err
}
token := RandStringRunes(12)
pa... |
package http
import (
"reflect"
"net/http"
"fmt"
"strconv"
"encoding/json"
"regexp"
"github.com/mskoroglu/golaxy/http/request/path"
"github.com/mskoroglu/golaxy/http/request"
"github.com/mskoroglu/golaxy/view"
"github.com/mskoroglu/golaxy/config"
)
type handlerFunc struct {
path string
method stri... |
package utils
import (
mcfgapi "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)
// IsMachineConfig checks if the specified object is a MachineConfig object
func IsMachineConfig(obj *unstructured.Unstructured) bool {
if o... |
package v1
import (
"encoding/json"
"fmt"
"net/http"
"wx-gin-master/models"
"wx-gin-master/models/user"
"wx-gin-master/pkg/app"
"wx-gin-master/pkg/e"
"wx-gin-master/pkg/util"
"github.com/astaxie/beego/validation"
"github.com/gin-gonic/gin"
)
const (
APP_KEY = "wxf5f58dbf63a03ed0"
APP_SECRET = "1bb4430... |
package nats_jetstream
import (
"context"
"encoding/json"
"strings"
"time"
"github.com/nats-io/nats.go"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
"github.com/batchcorp/plumber/validate"
"github.com/batchcorp/plumber-schemas/build/go/protos/args"
"github.com/batchcorp/plumber-schemas/build/g... |
package cmd
import (
"github.com/Files-com/files-cli/lib"
"github.com/spf13/cobra"
"fmt"
"os"
files_sdk "github.com/Files-com/files-sdk-go"
"github.com/Files-com/files-sdk-go/payment"
)
var (
Payments = &cobra.Command{
Use: "payments [command]",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command,... |
/*
Go Language Raspberry Pi Interface
(c) Copyright David Thorpe 2016-2017
All Rights Reserved
Documentation http://djthorpe.github.io/gopi/
For Licensing and Usage information, please see LICENSE.md
*/
// Interacts with the TSL2561 sensor over the I2C bus
package main
import (
"errors"
"fmt"
"os"
... |
package day4
import (
"bufio"
"bytes"
"fmt"
"io"
"os"
"reflect"
"regexp"
"sort"
"strconv"
"strings"
)
func loadData(reader io.Reader) [][]string {
scanner := bufio.NewScanner(reader)
scanner.Split(bufio.SplitFunc(SplitAt("\n\n")))
data := make([][]string, 0)
for scanner.Scan() {
data = append(data, ... |
package main
import (
"net/http"
"github.com/ThreeDotsLabs/wild-workouts-go-ddd-example/internal/common/auth"
"github.com/ThreeDotsLabs/wild-workouts-go-ddd-example/internal/common/server/httperr"
"github.com/ThreeDotsLabs/wild-workouts-go-ddd-example/internal/trainer/domain/hour"
"github.com/go-chi/render"
)
t... |
package textbox
type Point struct {
X, Y int
}
func (p Point) Move(x, y int) Point {
return Point{p.X + x, p.Y + y}
}
type Box struct {
win *Window
topLeft, bottomRight Point
topLeftFunc, bottomRightFunc func() Point
fillFunc func(*Box)
}
func (w *Window) B... |
// Copyright 2018 The OPA Authors. All rights reserved.
// Use of this source code is governed by an Apache2
// license that can be found in the LICENSE file.
package opa
import (
"encoding/json"
"io"
"reflect"
"testing"
)
func TestHTTPClientMakePatch(t *testing.T) {
tests := []struct {
prefix string
path... |
// Copyright 2018 Diego Bernardes. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package repository
import (
"context"
"fmt"
"net/url"
"sort"
"strings"
"sync"
"time"
"github.com/pkg/errors"
"github.com/satori/go.uuid"
"github.c... |
package osbuild2
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewDracutStage(t *testing.T) {
expectedStage := &Stage{
Type: "org.osbuild.dracut",
Options: &DracutStageOptions{},
}
actualStage := NewDracutStage(&DracutStageOptions{})
assert.Equal(t, expectedStage, actualStage)
}
|
// Copyright 2021 PingCAP, 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 to i... |
/*
Created by jinhan on 17-10-18.
Tip:
Update:
*/
package home
import (
"encoding/json"
"fmt"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
_ "github.com/go-sql-driver/mysql"
"os"
"testing"
//"time"
)
func init() {
beego.LoadAppConfig("ini", "../../conf/app.conf")
Connect()
}
// in hea... |
/*
Tencent is pleased to support the open source community by making Basic Service Configuration Platform available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except
in compliance with the License. You may obtain... |
package listing
import (
"time"
)
// Post defines the storage form of a post
type Post struct {
ID string `json:"id"`
Body string `json:"body"`
Created time.Time `json:"time"`
}
|
// Copyright 2022 PingCAP, 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 to i... |
// Copyright 2016, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package zktopo
import (
"github.com/youtube/vitess/go/vt/topo"
"golang.org/x/net/context"
"launchpad.net/gozk/zookeeper"
)
// Error codes returned by the zook... |
package activemq
import (
"context"
"github.com/go-stomp/stomp"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/batchcorp/plumber/types"
"github.com/batchcorp/plumber/validate"
"github.com/batchcorp/plumber-schemas/build/go/protos/args"
"github.com/batchcorp/plumber-schemas/build/go/protos/... |
package main
import (
"encoding/json"
"fmt"
)
func main() {
var jsonBlob = []byte(`[
{"Name": "Platypus"},
{"Name": "Quoll", "order": false}
]`)
type Animal struct {
Name string `json:"name"`
Order bool `json:"order"`
}
var animals []Animal
err := json.Unmarshal(jsonBlob, &animals... |
package main
import (
_ "embed"
"os"
"text/template"
)
// START DATA OMIT
var data = struct {
Company string
Employees []string
Features map[string]bool
}{
"Weave",
[]string{"Carson", "Kari", "Tami", "Raul"},
map[string]bool{
"beta-db": true,
"new-ui": false,
},
}
// END DATA OMIT
const templateTe... |
package client
import (
"bytes"
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
"net"
"net/http"
"os"
"os/exec"
"runtime"
"strconv"
"strings"
"time"
"github.com/hashicorp/mdns"
"github.com/ninjasphere/go-ninja/api"
"github.com/ninjasphere/go-ninja/bus"
"github.com/ninjasphere/go-ninja/config"
"github... |
package controller
import (
"github.com/gin-gonic/gin"
"net/http"
)
func GetUserList(c *gin.Context) {
c.HTML(http.StatusOK,"userList.html",nil)
}
func GetUserView(c *gin.Context) {
c.HTML(http.StatusOK,"userView.html",nil)
}
func GetUserAdd(c *gin.Context) {
c.HTML(http.StatusOK,"userAdd.html",nil)
}
func GetUs... |
package mail_relay
import (
"time"
"github.com/google/uuid"
)
type MailRelayRequest struct {
FirstName string `json:"first_name" binding:"required"`
LastName string `json:"last_name" binding:"required"`
ZipCode string `json:"zip_code" binding:"required"`
Email ... |
package entity
//func GetUserDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
// return GetDBWithModel(defDB, new(models.SysUser))
//}
|
/*
* @lc app=leetcode.cn id=9 lang=golang
*
* [9] 回文数
*/
// @lc code=start
package main
import "fmt"
func isPalindrome(x int) bool {
if x < 0 {
return false
}
y := x
reverse := 0
for y > 0 {
reverse = reverse*10 + y%10
y = y / 10
}
return reverse == x
}
// @lc code=end
func main() {
fmt.Printf("... |
package alerting
import (
"net/http"
"github.com/square/p2/pkg/util"
)
// Currently the Alerter interface only has a single implementation for PagerDuty. As a result,
// AlertInfo has information that PagerDuty needs, and other integrations may not. As a result,
// some information here may be ignored in future im... |
package main
import (
"fmt"
"html/template"
"net/http"
"os"
"os/exec"
)
// NotesHome = Root directory of Notes
const NotesHome = "/home/henan/go/src/notes"
// Notes doc is the document containing markdown formatted notes
const Notes = "/home/henan/Documents/notes"
func main() {
fileInfo, err := os.Lstat(Notes... |
package defaultController
import (
"github.com/krix38/gophotogallery/properties"
"github.com/krix38/gophotogallery/model/dao"
"github.com/krix38/gophotogallery/web/controller"
"encoding/json"
"net/http"
"strconv"
"regexp"
"log"
)
func mainView(w http.ResponseWriter, r *http.Request) {
/*galleries, err := dao... |
package encode
import (
"strings"
"fmt"
"unicode"
)
type pair struct {
count int
character byte
}
// Run Length Encoding algorithms
func RunLengthEncode(input string) string {
if len(input) == 0 {
return ""
}
return encodePairs(countingPairs(input))
}
func countingPairs(input string) []pair {
pairs := [... |
package keeper
import (
"context"
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/octalmage/gitgood/x/gitgood/types"
)
func (k msgServer) CreateAchievement(goCtx context.Context, msg *types.MsgCreateAchievement) (*types.MsgCreateAchievementRespons... |
package micro
import (
"fmt"
"mix/core/logger"
"mix/core/storage"
"mix/plugins/mysql"
"os"
"strings"
)
type IO struct {
Name string
Field map[string]string
}
func NewMethod() *Method {
m := new(Method)
m.InputFields = new(IO)
m.InputFields.Field = make(map[string]string)
m.OutputFields = new(IO)
m.Outp... |
package main
import (
"context"
"grpc-client-sample/proto"
"google.golang.org/grpc"
)
func main() {
con, err := grpc.Dial("localhost:7001", grpc.WithInsecure())
if err != nil {
panic(err)
}
client := proto.NewAddServiceClient(con)
req := proto.Request{A: 2, B: 4}
ctx := context.Background()
response... |
/*
Background
Densely packed decimal (DPD) is a way to efficiently store decimal digits in binary. It stores three decimal digits (000 to 999) in 10 bits, which is much more efficient than naive BCD (which stores one digit in 4 bits).
Notations
The lowercase letters a to i are the bits that are copied to the decimal ... |
package t2m
import (
"os"
"reflect"
"testing"
)
type Config struct {
FieldBool bool
FieldInt int
FieldInt8 int8
FieldInt16 int16
FieldInt32 int32
FieldInt64 int64
FieldUint uint
FieldUint8 uint8
FieldUint16 uint16
FieldUint32 uint32
FieldUint64 uint64
FieldString string
FieldF... |
package main
import (
"os"
"os/exec"
"time"
)
// leak example
// need kill PID after run
// recomend open another terminal
// run command `kill PID` or `top` or `htop`
// for sh -c
const cmdline = `
x=1
while true; do
printf "%s\n" "$x loops PLEAS \"kill $$\" on another terminal"
x=$((x + 1))
sleep 1
[ $x... |
package strategy
import "time"
type TreeStruct struct {
node []*NodeStruct
children []*TreeStruct
parent *TreeStruct
high int //计算层高
leaf bool
childLeafNum int
}
type NodeStruct struct {
data []byte
name []byte
length int
/**
* 数据的创建时间,隐藏数据不展示,通过该key值进行树的检索和排序
* 第一次创... |
package handlers
import (
"encoding/json"
"net/http"
"net/url"
"time"
"github.com/google/uuid"
"github.com/ory/fosite"
"github.com/ory/fosite/token/jwt"
"github.com/pkg/errors"
"github.com/valyala/fasthttp"
"github.com/authelia/authelia/v4/internal/middlewares"
"github.com/authelia/authelia/v4/internal/oi... |
package setr
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00200103 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:setr.002.001.03 Document"`
Message *RedemptionBulkOrderCancellationRequestV03 `xml:"RedBlkOrdrCxlRe... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.