text stringlengths 11 4.05M |
|---|
// Sample program to show how only types that can have equality defined on them
// can be a map key.
package main
// user represents someone using the program.
type user struct {
name string
surname string
}
// users defines a set of users.
type users []user
func main() {
// Declare and make a map that uses ... |
// Copyright 2019 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 main
import (
"fmt"
"image"
"image/color"
"image/png"
"os"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("Usage: colors filename")
return
}
file, _ := os.Open(os.Args[1])
image, _ := png.Decode(file)
count, out := countColors(image)
fmt.Printf("%d unique colors\n%d repeat col... |
package main
import (
"context"
"flag"
"log"
"net/http"
"os"
"os/signal"
"syscall"
"time"
"github.com/jsteenb2/health/internal/health"
"github.com/jsteenb2/health/internal/httpmw"
"github.com/jsteenb2/health/internal/server"
)
func main() {
var (
bindAddr = flag.String("bind", "127.0.0.1:8080", "addr... |
package main
import (
"gobot/modules"
"gobot/common"
)
func main() {
bot := common.BOT("irc.quakenet.org:6667", "gobot", "#Dolfik", []string{ "#dolfik", "#Lover.ee" })
bot.RegisterModule(modules.LOGGER(bot))
bot.RegisterModule(modules.NewWeatherModule(bot))
bot.RegisterModule(modules.NewQuoteModule(bot))
bot.R... |
/*
Copyright 2020 The Kubernetes 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, ... |
package l64
import (
"testing"
"gotest.tools/assert"
)
func Test_minPathSum(t *testing.T) {
tests := []struct {
name string
want int
input [][]int
}{
{
want: 7,
input: [][]int{
{1, 3, 1},
{1, 5, 1},
{4, 2, 1},
},
},
}
for _, tt := range tests {
output := minPathSum(tt.input)
... |
package consul
import (
"log"
)
// Watch listening to the service in Consul
func (client *Client) Watch() <-chan AvailableServers {
if len(client.discoveryConfigs) == 0 {
return nil
}
client.once.Do(func() {
for _, sdConfig := range client.discoveryConfigs {
go func(sdConfig *DiscoveryConfig) {
if err... |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
//Implicit declaration, hehehe
scanner := bufio.NewScanner(os.Stdin)
fmt.Println("Enter the year of your birth: ")
scanner.Scan()
input, _ := strconv.ParseInt(scanner.Text(), 0, 64)
fmt.Printf("You wil be %d years old at the end of 2020... |
package main
import (
"bytes"
"crypto/md5"
"encoding/json"
"fmt"
"html/template"
"io"
"log"
"net/http"
"os"
"reflect"
"strconv"
"strings"
"time"
)
type Product struct {
Pid int
Product_name string
Image_url string
Product_Code string
Supplier_Id int
}
type header struct {
Encryption string `json:... |
package main
import (
"github.com/spf13/cobra"
"github.com/alejandroEsc/maas-cli/pkg/cli"
)
func listCmd() *cobra.Command {
mo := &cli.ListOptions{}
cmd := &cobra.Command{
Use: "list",
Short: "list MAAS resources.",
Long: "",
Run: func(cmd *cobra.Command, args []string) {
cmd.Usage()
},
}
fs :... |
package simulation
import (
"bytes"
"fmt"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/kv"
"github.com/irisnet/irismod/modules/nft/types"
)
// DecodeStore unmarshals the KVPair's Value to the corresponding gov type
func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB kv.Pair) stri... |
package debugger
import "fmt"
func Example() {
pid, err := FindPidByPs("/home/oneu/ccpos/dist/ccpos")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(pid)
bp := BreakPoint(pid, 0x014d7da8)
bp.Enable()
}
|
package types
import (
// HOFSTADTER_START import
// HOFSTADTER_END import
)
/*
Name: User
About: A user of the blog site
*/
// HOFSTADTER_START start
// HOFSTADTER_END start
func NewUser() *User {
return &User{}
}
func NewAuthBasicUserSignupRequest() *AuthBasicUserSignupRequest {
return &AuthBasicU... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//740. Delete and Earn
//Given an array nums of integers, you can perform operations on the array.
//In each operation, you pick any nums[i] and delete... |
package helpers
import (
"bufio"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"net/url"
"os"
"path"
"path/filepath"
"strconv"
"strings"
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
"github.com/docker/... |
package object
import (
"encoding/binary"
"unsafe"
"github.com/tidwall/geojson"
"github.com/tidwall/geojson/geometry"
"github.com/tidwall/tile38/internal/field"
)
type pointObject struct {
base Object
pt geojson.SimplePoint
}
type geoObject struct {
base Object
geo geojson.Object
}
const opoint = 1
con... |
package main
import (
"fmt"
"html"
"log"
"net/http"
"time"
)
type hijackHandler struct{}
func (hijackHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
hj, ok := w.(http.Hijacker)
if !ok {
http.Error(w, "webserver doesn't support hijacking", http.StatusInternalServerError)
return
}
time.Sleep(... |
package entities
type BirdVoteResponse struct {
BirdId int `json:"bird_id"`
Votes int `json:"votes"`
Description string `json:"description"`
} |
package shamir_test
import (
"math/rand"
"testing"
"time"
"github.com/renproject/secp256k1"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/renproject/shamir"
. "github.com/renproject/shamir/shamirutil"
)
// The key properties of verifiable secret sharing is that it is the same as
// nor... |
package main
import (
"encoding/json"
"log"
"net/http"
"time"
"github.com/gorilla/mux"
)
var bookings []Spot
func main() {
r := mux.NewRouter()
// Create Mock data
bookings = append(bookings, Spot{ID: "1", BookedDate: time.Date(2021, 9, 4, 0, 0, 0, 0, time.Now().Location()), BookingStatus: "NB", BookedOn: ... |
package service
import (
"context"
"errors"
"git.dustess.com/mk-base/log"
"git.dustess.com/mk-training/mk-blog-svc/pkg/blog/dao"
"git.dustess.com/mk-training/mk-blog-svc/pkg/blog/model"
statDao "git.dustess.com/mk-training/mk-blog-svc/pkg/blogstatistics/dao"
statModel "git.dustess.com/mk-training/mk-blog-svc/pk... |
package gogacap
import (
"testing"
)
import (
"fmt"
)
func sliceEq(a, b []int) bool {
if len(a) != len(b) {
return false
}
for i := 0; i != len(a); i++ {
if a[i] != b[i] {
return false
}
}
return true
}
func sliceLt(a, b []int) bool {
i, j := 0, 0
for i < len(a) && j < len(b) && a[i] == b[j] {
... |
package client
import (
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
var DB *gorm.DB
func init() {
db_, err := gorm.Open(sqlite.Open(""), &gorm.Config{})
if err != nil {
panic(err)
}
DB = db_
}
|
// Package forkexec provides interface to run a subprocess with seccomp filter, rlimit and
// containerized or ptraced.
//
// unshare cgroup namespace requires kernel >= 4.6
// seccomp, unshare pid / user namespaces requires kernel >= 3.8
// pipe2, dup3 requires kernel >= 2.6.27
package forkexec
|
package wappin
import (
"github.com/jarcoal/httpmock"
"github.com/stretchr/testify/assert"
"testing"
)
func TestSendNotificationHSM(t *testing.T) {
httpmock.ActivateNonDefault(client.GetClient())
defer httpmock.DeactivateAndReset()
mockGetAccessToken()
fixture := `{ "message_id": "id-123", "status": "200", "m... |
package main
import (
"fmt"
)
func main() {
fmt.Println(hardestWorker(70, [][]int{{36, 3}, {1, 5}, {12, 8}, {25, 9}, {53, 11}, {29, 12}, {52, 14}}))
}
func hardestWorker(n int, logs [][]int) int {
if len(logs) == 1 {
return logs[0][0]
}
ans := logs[0][1] // 取第一个 耗时
idx := logs[0][0] // 取第一个 id
for i := 1... |
package main
import (
"log"
"os"
"time"
"github.com/faiface/beep"
"github.com/faiface/beep/mp3"
"github.com/faiface/beep/speaker"
)
func main() {
f, err := os.Open("../Lame_Drivers_-_01_-_Frozen_Egg.mp3")
if err != nil {
log.Fatal(err)
}
streamer, format, err := mp3.Decode(f)
if err != nil {
log.Fata... |
//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -o zz_search_test.go ../../../../../vendor/github.com/go-air/gini/inter S
package solver
import (
"context"
"testing"
"github.com/go-air/gini/inter"
"github.com/go-air/gini/z"
"github.com/stretchr/testify/assert"
)
type TestScopeCounter struct {
de... |
package main
import (
"context"
"flag"
"fmt"
"log"
"net"
pb "github.com/rifannurmuhammad/go-grpc/movie/proto"
"google.golang.org/grpc"
)
var (
port = flag.Int("port", 6565, "The server port")
)
type movieServer struct {
pb.MovieMessageList
pb.MovieMessage
pb.UnimplementedMovieServiceServer
}
func (s *m... |
package spec
import (
"github.com/agiledragon/trans-dsl"
)
type IsDefExist struct {
}
func (this *IsDefExist) Ok(transInfo *transdsl.TransInfo) bool {
return true
}
|
package queueinformer
import (
"context"
"testing"
"time"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/version"
)
type versionFunc func() (*version.Info, error)
func (f versionFunc) ServerVersion() (*version.Info, error) {
if f == nil {
return &version.Info{}, nil
}
return (func() (*version.Info, erro... |
// Copyright 2018 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 dto
import (
"bytes"
"encoding/binary"
"fmt"
)
//This is Header of the message that is send to node. Each message must be preceded by this header.
type Header struct {
TaskId int64
Type int32
DataSize int32
DeviceId int32
}
func (h *Header) String() string {
return fmt.Sprintf("#%d Code: %d [%d... |
/*
当前市场深度
返回当前市场深度(委托挂单),其中 asks 是委卖单, bids 是委买单。
请替换 [CURR_A] and [CURR_B] 为您需要查看的币种.
http://data.gate.io/api2/1/orderBook/[CURR_A]_[CURR_B]
*/
package main
import (
"github.com/buger/jsonparser"
"strconv"
"errors"
"encoding/json"
)
type ApiOrderBook struct {
Api
Pair string
Result bool
asks []ApiDepth
... |
package storage
import (
"bytes"
"context"
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
)
func TestLocal(t *testing.T) {
ts := []struct {
name string
uri string
data []byte
}{
{
name: "normal data",
uri: "testfile1",
data: []byte("hello local storage"),
... |
package util
import (
"io/ioutil"
"testing"
"github.com/ghodss/yaml"
"github.com/pmezard/go-difflib/difflib"
"github.com/stretchr/testify/require"
yaml2 "gopkg.in/yaml.v2"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)
// ReadAsset reads an asset from the filesystem, panicking in case of error
func Rea... |
package sdk
const (
KafkaPlatformModel = "Kafka"
)
var (
// KafkaPlatform represent a kafka platform
KafkaPlatform = PlatformModel{
Name: KafkaPlatformModel,
Author: "CDS",
Identifier: "github.com/ovh/cds/platform/builtin/kafka",
Icon: "",
DefaultConfig: PlatformConfig{
"broker url": P... |
package cfmysql_test
import (
"code.cloudfoundry.org/cli/cf/errors"
"code.cloudfoundry.org/cli/plugin"
"code.cloudfoundry.org/cli/plugin/models"
"code.cloudfoundry.org/cli/plugin/pluginfakes"
"fmt"
. "github.com/andreasf/cf-mysql-plugin/cfmysql"
"github.com/andreasf/cf-mysql-plugin/cfmysql/cfmysqlfakes"
. "git... |
package cli
import (
"errors"
"strings"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/gookit/gcli/v3"
"github.com/ovrclk/akcmd/client"
"github.com/ovrclk/akcmd/flags"
)
// GetBroadcastCommand returns the tx broadcast command.
func GetBroadcastCommand() *gcli.Command {
cmd := &gcli.Comman... |
package ionic
import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
)
const (
sessionsLoginEndpoint = "v1/sessions/login"
)
// Session represents the BearerToken and User for the current session
type Session struct {
BearerToken string `json:"jwt"`
User User `json:"user"`
}
type Login... |
package topsort
import (
"fmt"
"strings"
)
type Graph struct {
nodes map[string]node
}
func NewGraph() *Graph {
return &Graph{
nodes: make(map[string]node),
}
}
func (g *Graph) AddNode(name string) {
if !g.ContainsNode(name) {
g.nodes[name] = make(node)
}
}
func (g *Graph) AddEdge(from string, to string... |
package 链表
// ------------------------- 方法1: 暴力K路归并 -------------------------
// 执行用时:320 ms, 在所有 Go 提交中击败了 10.75% 的用户
// 内存消耗:5.3 MB, 在所有 Go 提交中击败了 100.00% 的用户
const INF = 1000000000
const cantFindOutIndexFlag = -1
func mergeKLists(lists []*ListNode) *ListNode {
dummyHead := &ListNode{}
cur := dummyHead
for {
mi... |
/*
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... |
/*
* Copyright 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 compliance with the Lic... |
package mime
const (
ContentTypeHeader = "content-type"
ApplicationJSON = "application/json"
ApplicationForm = "application/x-www-form-urlencoded"
)
|
package server
import (
"coreydaley.com/mailgoon/api"
"database/sql"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"testing"
"time"
"coreydaley.com/mailgoon/database"
)
func TestServerAPIKeyNoDatabase(t *testing.T) {
d := database.Database{}
if err := d.New("/tmp/test.db"); err != nil {
t.Errorf("U... |
// Copyright 2015 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 draw
func init() {
SystemInstace = &System{}
}
|
package util
import (
"fmt"
"github.com/spf13/pflag"
"strings"
"github.com/fsnotify/fsnotify"
"github.com/spf13/viper"
)
// InitialiseConfig initialises a generic config.
//
// Any registered flags are available as environment variables under the `[APP]` prefix:
// e.g. db.username => BACKEND_DB.USERNAME=backen... |
package parser
import (
"github.com/goodwine/yaaji/parser/structures"
"github.com/goodwine/yaaji/tokenizer"
)
func Parse(tokens []tokenizer.Token) structures.Structure {
var root structures.Structure = &structures.Code{}
tree := root
for _, token := range tokens {
tree = tree.Add(structures.Structurify(token))... |
package model
type PresetConfiguration string
// List of PresetConfiguration
const (
PresetConfiguration_LIVE_HIGH_QUALITY PresetConfiguration = "LIVE_HIGH_QUALITY"
PresetConfiguration_LIVE_LOW_LATENCY PresetConfiguration = "LIVE_LOW_LATENCY"
PresetConfiguration_VOD_HIGH_QUALITY PresetConfiguration = "VOD_HIGH_QUAL... |
package main
import (
"fmt"
"net"
"strconv"
"bufio"
)
const (
defaultHost = "localhost"
defaultPort = 9999
)
// To test your server implementation, you might find it helpful to implement a
// simple 'client runner' program. The program could be very simple, as long as
// it is able to connect with and send ... |
package main
import (
"fmt"
"math"
)
type Circle struct {
x, y, r float64
}
func (c *Circle) getArea() float64 {
return math.Pi * c.r * c.r
}
func main() {
c := Circle{10, 20, 10}
fmt.Println(c.getArea())
}
|
package main
import (
"context"
"errors"
"fmt"
"net/http"
"os"
"os/signal"
"syscall"
"time"
"golang.org/x/sync/errgroup"
)
// server: 提供http服务
func server(ctx context.Context, addr string) error {
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {
fmt.Fprintf(w,... |
package main
import (
"testing"
)
func TestFindMode(t *testing.T) {
}
|
/*
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 errors
var ErrNoID = New("user's ID not specified", 400)
var ErrUserNotFound = New("user not found", 404)
|
package testing
import (
"context"
"github.com/brigadecore/brigade/sdk/v3"
)
type MockSubstrateClient struct {
CountRunningWorkersFn func(
context.Context,
*sdk.RunningWorkerCountOptions,
) (sdk.SubstrateWorkerCount, error)
CountRunningJobsFn func(
context.Context,
*sdk.RunningJobCountOptions,
) (sdk.S... |
package main
import (
"fmt"
"strings"
)
/**
面试题 16.18. 模式匹配
你有两个字符串,即`pattern`和`value`。
`pattern`字符串由字母`"a"`和`"b"`组成,用于描述字符串中的模式。
例如,字符串`"catcatgocatgo"`匹配模式`"aabab"`(其中`"cat"`是`"a"`,`"go"`是`"b"`),该字符串也匹配像`"a"`、`"ab"`和`"b"`这样的模式。
但需注意`"a"`和`"b"`不能同时表示相同的字符串。编写一个方法判断`value`字符串是否匹配`pattern`字符串。
示例1:
```
输入: pattern... |
package viewmodel
type SuccesVM struct {
Data interface{} `json:"data,omitempty"`
Message string `json:"message,omitempty"`
}
|
package models
import "github.com/jinzhu/gorm"
type Article struct {
gorm.Model
Category int
Title string
Tags string
Content string
Author string
Status int
Intro string
OuterLink string
}
func (Article) TableName() string {
return "article"
}
|
/*
* Copyright 2018, CS Systemes d'Information, http://www.c-s.fr
*
* 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 requir... |
package bardo
import (
"regexp"
)
var dbNameR = regexp.MustCompile(`dbname\=([^\s]+?)\s`)
// GetDBNameFromURL
// Get the database name from the open string
func GetDBNameFromURL(url string) string {
// Find database name (that we will create)
m := dbNameR.FindStringSubmatch(url)
return m[1]
}
// ReplaceDBNameI... |
package parcels
import (
"context"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"spWebFront/FrontKeeper/infrastructure/bolt"
"spWebFront/FrontKeeper/infrastructure/core"
"spWebFront/FrontKeeper/infrastructure/memfile"
"spWebFront/FrontKeeper/server/app/domain/service/searcher/docum... |
package ibmcloud
// Platform stores all the global configuration that all machinesets use.
type Platform struct {
// Region specifies the IBM Cloud region where the cluster will be
// created.
Region string `json:"region"`
// ResourceGroupName is the name of an already existing resource group where the
// cluste... |
package conf
import (
"io"
"os"
"sort"
"strings"
"github.com/spf13/viper"
"github.com/bolaxy/common/hexutil"
"github.com/bolaxy/crypto"
"github.com/bolaxy/rlp"
)
type Genesis struct {
CoinBase string `mapstructure:"coinbase"`
ChainID string `mapstructure:"chain-id"`
ConsensusAccoun... |
/*
Given an m x n matrix, return all elements of the matrix in spiral order.
Example 1:
Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]
Output: [1,2,3,6,9,8,7,4,5]
Input: matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
Output: [1,2,3,4,8,12,11,10,9,5,6,7]
Constraints:
m == matrix.length
n == matrix[i].length
1 <= m, n <= 10... |
package calc
type TokenType int
type Token struct {
Type TokenType
Value string
}
var eof = rune(0)
const (
NUMBER TokenType = iota
LPAREN
RPAREN
CONSTANT
FUNCTION
OPERATOR
WHITESPACE
ERROR
EOF
)
|
// mp3rwInfo
package main
import (
"errors"
"flag"
"fmt"
"io"
"os"
"strings"
)
type mp3Tag struct {
title string
artist string
album string
year string
comment string
}
func flags() (string, string, string, string, string, string) {
sPath := flag.String("Path", "", "Path")
sTitle := flag.String... |
package h2quic
import (
"bytes"
"errors"
"io/ioutil"
"net/http"
"net/textproto"
"strconv"
"strings"
"golang.org/x/net/http2"
)
// copied from net/http2/transport.go
var errResponseHeaderListSize = errors.New("http2: response header list larger than advertised limit")
var noBody = ioutil.NopCloser(bytes.NewR... |
/*
Copyright 2018 The Kubernetes 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, ... |
//
// Copyright (c) 2015-2017 Snowplow Analytics Ltd. All rights reserved.
//
// This program is licensed to you under the Apache License Version 2.0,
// and you may not use this file except in compliance with the Apache License Version 2.0.
// You may obtain a copy of the Apache License Version 2.0 at http://www.apach... |
package simulation
import (
"encoding/json"
"fmt"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/irisnet/irismod/modules/nft/types"
)
const (
kitties = "kitties"
doggos = "doggos"
)
// RandomizedGenState generates a random GenesisState for n... |
package binance
import (
"context"
"net/http"
)
// FiatDepositWithdrawHistoryService retrieve the fiat deposit/withdraw history
type FiatDepositWithdrawHistoryService struct {
c *Client
transactionType TransactionType
beginTime *int64
endTime *int64
page *int32
rows ... |
/* nighthawk.audit.parser.systeminfo.go
* author: roshan maskey <roshanmaskey@gmail.com>
*
* Parser for SystemInformation
*/
package parser
import (
"fmt"
"os"
"encoding/xml"
"strings"
"nighthawk/elastic"
nhconfig "nighthawk/config"
nhs "nighthawk/nhstruct"
nhutil "nighthawk/util"
nhlog "nigh... |
// Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0.
package checksum
import (
"context"
"github.com/gogo/protobuf/proto"
"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
"github.com/pingcap/log"
"github.com/pingcap/tidb/br/pkg/metautil"
"github.com/pingcap/tidb/br/pkg/utils"
"github.com/ping... |
package rss
import(
"encoding/xml"
"encoding/json"
)
type RSS struct {
Channel Channel `xml:"channel" json:"channel"`
}
type Channel struct {
Title string `xml:"title" json:"title"`
Link string `xml:"link" json:"link"`
Description string `xml:"description" json:"description"`
Language string `xml:"language... |
package main
import "fmt"
func main() {
// 声明一个map; map[keyType]valueType
nameAgeMap := make(map[string]int)
//赋值
nameAgeMap["wangwu"] = 11
nameAgeMap["liliu"] = 22
fmt.Println("liliu old age: ", nameAgeMap["liliu"])
// 修改值
nameAgeMap["liliu"] = 33
fmt.Println("liliu new age: ", nameAgeMap["liliu"])
//初始化一... |
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"time"
"net"
"crypto/tls"
)
var count int64
func argsHandler(w http.ResponseWriter, r *http.Request) {
var s string
for i := 0; i < len(os.Args); i++ {
s += os.Args[i]
}
fmt.Fprint(w, s)
}
func reqTestHandler(w http.ResponseWriter, r *http.... |
package v1
import "github.com/gin-gonic/gin"
type Tag struct{}
func NewTag() *Tag {
return &Tag{}
}
func (t *Tag) Get(c *gin.Context) {}
func (t *Tag) List(c *gin.Context) {}
func (t *Tag) Create(c *gin.Context) {}
func (t *Tag) Update(c *gin.Context) {}
func (t *Tag) Delete(c *gin.Context) {}
|
package main
import "fmt"
import "testing"
func TestCheck(t *testing.T) {
fmt.Println("Test: Parenthesis")
f := "()"
fmt.Println(check(f))
fmt.Println()
}
func TestCheck2(t *testing.T) {
fmt.Println("Test: All brackets")
f := "()[]{}"
fmt.Println(check(f))
fmt.Println()
}
func TestCheck3(t *testing.T... |
package server
import (
"net/http"
"github.com/cinus-ue/securekit/common/errorx"
log "github.com/cinus-ue/securekit/common/log15"
"github.com/cinus-ue/securekit/internal/webapps/fileserver/param"
"github.com/cinus-ue/securekit/internal/webapps/fileserver/tpl"
"github.com/cinus-ue/securekit/internal/webapps/file... |
package leetcode
import (
"reflect"
"testing"
)
func TestFindOcurrences(t *testing.T) {
ans1 := findOcurrences("alice is a good girl she is a good student", "a", "good")
if !reflect.DeepEqual(ans1, []string{"girl", "student"}) {
t.Fatal()
}
ans2 := findOcurrences("we will we will rock you", "we", "will")
if ... |
package funciones
import (
"math"
"strconv"
"fmt"
)
const (
// Constante del radio de la tierra aproximado
radio = 6373000
// medidas que son las que debería ir ajustando
P = 0.95
EPSILON = 0.0001
EPSILONP = 0.001
L = 1000
PHI = .90
)
// Funcion que saca la gráfica completa de las ciudades
func Completa(c... |
package example
// NOTE: THIS FILE WAS PRODUCED BY THE
// MSGP CODE GENERATION TOOL (github.com/tinylib/msgp)
// DO NOT EDIT
import (
"github.com/tinylib/msgp/msgp"
)
// DecodeMsg implements msgp.Decodable
func (z *MyEvalResult) DecodeMsg(dc *msgp.Reader) (err error) {
{
var ssz uint32
ssz, err = dc.ReadArrayH... |
package window
import (
"testing"
)
func TestInitGlfw(t *testing.T) {
t.Skip("Unimplemented")
}
func TestDummyKeyCallback(t *testing.T) {
t.Skip("Unimplemented")
}
func TestDummyMouseButtonCallback(t *testing.T) {
t.Skip("Unimplemented")
}
|
// Pointers to a struct
// Pointers in Go programming language or Golang is a variable
// which is used to store the memory address of another variable.
// Golang program to illustrate
// the pointer to struct
package main
import "fmt"
// defining a structure
type Employee struct {
firstName, lastName string
age,... |
/*
Copyright 2020 The Kubernetes 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, ... |
package main
import "fmt"
func main() {
upSpeed := 6
downSpeed := 5
desiredHeight := 10
count := 0
//oneDay := upSpeed - downSpeed
total := upSpeed
count++
for total < desiredHeight {
total -= downSpeed
//fmt.Println(oneDay)
total += upSpeed
count++
}
fmt.Println(count)
}
|
package async
import "net/http"
//NewClient 함수는 새 클라이언트를 만들고
//적절한 채널을 설정한다.
func NewClient(client *http.Client, bufferSize int) *Client {
respch := make(chan *http.Response, bufferSize)
errch := make(chan error, bufferSize)
return &Client{
Client: client,
Resp: respch,
Err: errch,
}
}
//Client 구조체는 클라이언트를... |
// Copyright 2018 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 sms
import (
"encoding/json"
"github.com/gin-gonic/gin"
"github.com/zhuiyi1997/go-gin-api/app/config"
"github.com/zhuiyi1997/go-gin-api/app/model"
"github.com/zhuiyi1997/go-gin-api/app/util/request"
"log"
"math/rand"
"net/url"
"strconv"
"time"
)
func SendSms(tp,phone string) (bool,error) {
rand.See... |
package chartjs
import (
"github.com/gopherjs/gopherjs/js"
)
type Chart struct {
*js.Object
}
func NewChart(ctx *js.Object, config *Config) *Chart {
return &Chart{Object: js.Global.Get("Chart").New(ctx, config)}
}
func GetChart(name string) *Chart {
return &Chart{Object: js.Global.Get("document").Get(name)}
}
... |
package main
import (
"context"
"encoding/json"
"fmt"
"math"
"math/rand"
"net"
"net/http"
"net/url"
"os"
"os/signal"
"path/filepath"
"sort"
"strconv"
"strings"
"sync"
"syscall"
"time"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/improbable-eng/thanos/pkg/alert"
"githu... |
package main
import "fmt"
func main() {
a := "James"
num := 45
foo()
bar(a)
add(&num)
fmt.Println("My name is still", a)
fmt.Println("Main: The num:", num)
}
func foo() {
fmt.Println("My name is James")
}
func bar(s string) {
s = "John"
fmt.Println("My name is", s)
}
func add(x *int) {
fmt.Println("I... |
package main
import "github.com/gofiber/fiber/v2"
func main() {
app := fiber.New()
app.Post("/get_into_db", func(c *fiber.Ctx) error {
return c.SendString("Hello")
})
}
|
/*
* @lc app=leetcode.cn id=83 lang=golang
*
* [83] 删除排序链表中的重复元素
*/
// @lc code=start
/**
* Definition for singly-linked list.
*/
package main
import "fmt"
type ListNode struct {
Val int
Next *ListNode
}
func deleteDuplicates(head *ListNode) *ListNode {
// nums := map[int]int{}
// cur := head
// va... |
package relax
import (
"math"
"math/rand"
"strings"
"sync"
"time"
)
var (
rnd = rand.New(rand.NewSource(time.Now().Unix()))
)
type VolumeSlider struct {
stop chan bool
ticker *time.Ticker
mtx sync.Mutex
target float64
val float64
speed float64
}
func NewVolumeSlider() *VolumeSlider {
t := tim... |
package main
import (
"encoding/json"
"fmt"
"html/template"
"math/rand"
"net/http"
"os"
"time"
)
// NumberOfNumbers of each Combination
var NumberOfNumbers int = 5
// NumberOfStars of each Combination
var NumberOfStars int = 2
// Combination of a euromilions key
type Combination struct {
Numbers []int
Star... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.