text stringlengths 11 4.05M |
|---|
package mailmanv2
import (
"log"
"time"
"io/ioutil"
apns "github.com/joekarl/go-libapns"
)
const (
MAX_BUFFERED_MESSAGES = 100
)
var (
error_handlers = make(map[string]errorhandler)
apns_keys = make([]string, 0)
)
//
// Worker structure
//
type Worker struct {
Id int `json:"i... |
package appdata
import (
"github.com/project-flogo/core/activity"
"github.com/project-flogo/core/app"
"github.com/project-flogo/core/support/test"
"testing"
"github.com/stretchr/testify/assert"
)
func TestRegister(t *testing.T) {
ref := activity.GetRef(&Activity{})
act := activity.Get(ref)
assert.NotNil(t,... |
package models
import (
"database/sql"
"github.com/KashEight/not/utils"
"github.com/google/uuid"
"time"
)
type NotePostData interface {
ConvertToNoteContent() (*NoteContent, error)
}
type PostDataCreateNote struct {
Content string `json:"content"`
ExpiredTime *time.Time `json:"expired_time" time_forma... |
package customer
import (
"net/http"
"github.com/Top-Pattarapol/finalexam/database"
"github.com/gin-gonic/gin"
)
type Handler struct {
database *database.Handler
}
func (h *Handler) Init() {
database := &database.Handler{}
h.database = database
h.database.Open()
h.CreateCustomerTable()
}
func (h *Handler) ... |
// Copyright (c) 2016-2019 Uber Technologies, 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... |
package meta
import (
"database/sql"
_ "github.com/lib/pq"
)
// PgColumnMetadata contains metadata for domains
type PgDomainMetadata struct {
SchemaName string `db:"schema_name"`
ObjName string `db:"obj_name"`
DataType string `db:"data_type"`
TypeName string `db:"type_name"`
TypeCategory string... |
package statsdclient
import (
"strings"
)
// Generates a prefix in the form "environment.app.hostname.", where dots in
// the hostname are replaced with underscores so they don't conflict with stats
// dot namespacing
func MakePrefix(environment, app, hostname string) string {
underscoreHostname := strings.Replace(... |
package rpc
import (
"context"
"encoding/json"
"time"
"github.com/mylxsw/adanos-alert/internal/repository"
"github.com/mylxsw/adanos-alert/rpc/protocol"
"github.com/mylxsw/asteria/log"
"github.com/mylxsw/glacier/infra"
)
// HeartbeatService is a service server for heartbeat
type HeartbeatService struct {
cc ... |
package main
import (
"testing"
"gitlab.com/joukehofman/OTSthingy/types"
)
func TestInitVars(t *testing.T) {
initVars()
if logs == nil || cfg == nil {
t.Fail()
}
}
func TestStartGRPC(t *testing.T) {
startGRPC(&types.Requester{})
}
func TestStartPoller(t *testing.T) {
abortChan := make(chan bool, 5)
notif... |
package matrix_test
import (
"fmt"
"testing"
"github.com/carolove/Golang/algorithms/datageneration"
"github.com/carolove/Golang/algorithms/matrix"
)
func TestMatrixMul(t *testing.T) {
a := datageneration.GenerationMarix(2)
fmt.Println(a)
b := datageneration.GenerationMarix(2)
fmt.Println(b)
fmt.Println(matr... |
package user
import (
"context"
"fmt"
"os"
"testing"
"time"
"github.com/Al-un/alun-api/alun/testutils"
"github.com/Al-un/alun-api/alun/utils"
"github.com/Al-un/alun-api/pkg/logger"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
const (
userRegisterEmail = "register@test.... |
package Longest_Substring_Without_Repeating_Characters
import "testing"
func Test(t *testing.T) {
res := lengthOfLongestSubstring("abcabcbb")
t.Log(res)
}
|
package plugins
import (
"testing"
)
func TestNewConsolePlugin(t *testing.T) {
if _, ok := NewConsolePlugin().(*ConsolePlugin); !ok {
t.Fail()
}
}
func TestConsolePluginConfigure(t *testing.T) {
t.Run("configuration is nil", func(t *testing.T) {
c := NewConsolePlugin().(*ConsolePlugin)
expected :... |
package entity
import "time"
type User struct {
LineID string `db:"line_id"`
CalendarAccessToken string `db:"calendar_access_token"`
CalendarTokenType string `db:"calendar_token_type"`
CalendarRefreshToken string `db:"calendar_refresh_token"`
CalendarExpiry time.Time `db:"calendar_expiry"`
}
|
package handlers
import (
"fmt"
"strings"
)
func PrintBold(str string) {
fmt.Printf("\033[1m%s\033[0m", str)
}
func MakeBold(str string) string {
return fmt.Sprintf("\033[1m%s\033[0m", str)
}
func PrintSuccess(str string) {
fmt.Printf("\033[32;1m%s\033[0m", str)
}
func PrintTable(keys []string, values [][]str... |
//go:build e2e
package cloudnative
import (
"context"
"encoding/json"
"path"
"strconv"
"strings"
"testing"
"github.com/Dynatrace/dynatrace-operator/src/api/v1beta1"
dtcsi "github.com/Dynatrace/dynatrace-operator/src/controllers/csi"
"github.com/Dynatrace/dynatrace-operator/src/kubeobjects/address"
"github.... |
/*
Copyright 2021 Dynatrace LLC.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
... |
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information
//go:build linux || freebsd
// +build linux freebsd
package processgroup
import (
"os"
"os/exec"
"syscall"
)
// Setup sets up exec.Cmd such that it can be properly terminated.
func Setup(c *exec.Cmd) {
c.SysProcAttr = &syscall.SysProc... |
// 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, ... |
package simpletime
import (
"testing"
"time"
)
func TestParseFormat(t *testing.T) {
t.Parallel()
tests := []struct {
name string
format string
want string
}{
{
name: "year-month-day long",
format: "YYYY-MM-DD",
want: "2022-08-09",
},
{
name: "month/day/year short",
format: "... |
package auth
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/wyllisMonteiro/go-api-template/pkg/models"
)
// Register New account
// @Summary Create new account
// @Description Using JWT auth
// @Tags auth
// @Accept json
// @Produce json
// @Param body body models.RequestRegister true "Add account"
... |
// Copyright 2017 Walter Schulze
//
// 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... |
/*
Copyright 2022 Docker Compose CLI 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 a... |
/*
* Wire API
*
* Moov Wire implements an HTTP API for creating, parsing, and validating Fedwire messages.
*
* API version: v1
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package openapi
// OutputMessageAccountabilityData struct for OutputMessageAccountabilityData
type OutputMessageAc... |
package handler
import (
"golang.org/x/net/context"
pb "github.com/im-auld/gopherup/moderator-service"
"google.golang.org/grpc/grpclog"
"strings"
)
// NewService returns a naïve, stateless implementation of Service.
func NewService() pb.ModeratorServer {
return gopherupService{}
}
type gopherupService struct{}... |
package main
import (
"time"
"fmt"
)
func main() {
crutime:= time.Now()
fmt.Println(crutime)
testTime := time.Now().Unix()
fmt.Println(testTime)
}
|
package main
import (
"fmt"
mypackage "./mypackage"
)
func main() {
var myCar mypackage.CarPublic
myCar.Brand = "Ferrari"
myCar.Year = 2021
fmt.Println(myCar)
mypackage.Printmessage("Hello everyone")
}
|
package token
/**
网页授权access_token
微信网页授权是通过OAuth2.0机制实现的, 在用户授权给公众号后, 公众号可以获取到一个网页授权特有的接口调用凭证(网页授权access_token).
通过网页授权access_token可以进行授权后接口调用,如获取用户基本信息.
*/
type ApiToken string
func (token *ApiToken) GetToken() string {
}
func (token *ApiToken) RefreshToken() string {
}
|
package text
import (
"fmt"
"strings"
"github.com/aevea/quoad"
)
// ReleaseNotes holds the required settings for generating ReleaseNotes
type ReleaseNotes struct {
Complex bool
}
// Generate generates the output mentioned in the expected-output.md
func (r *ReleaseNotes) Generate(sections map[string][]quoad.Comm... |
package main
import (
"html/template"
"log"
"net/http"
)
var tpl *template.Template
func init() {
tpl = template.Must(template.ParseGlob("templates/*.gohtml"))
}
func index(w http.ResponseWriter, r *http.Request) {
page := "Index"
tpl.ExecuteTemplate(w, "index.gohtml", page)
}
func dog(w http.ResponseWriter,... |
package camo
import (
"runtime"
"testing"
)
func newRouteTestIface() (iface *Iface, err error) {
iface, err = NewTunIface(DefaultMTU)
if err != nil {
return nil, err
}
err = iface.SetIPv4("10.20.30.42/24")
if err != nil {
iface.Close()
return nil, err
}
err = iface.SetIPv6("fd00:cafe:1234::2/64")
if e... |
package container_test
import (
"errors"
"github.com/genevieve/leftovers/gcp/container"
"github.com/genevieve/leftovers/gcp/container/fakes"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Cluster", func() {
var (
client *fakes.ClustersClient
name string
cluster container.Clu... |
package main
import (
"context"
"fmt"
"os"
"github.com/docker/docker/client"
)
// Nagios return codes
const (
NagiosOk = 0
NagiosWarning = 1
NagiosCritical = 2
NagiosUnknown = 3
)
var version string
func main() {
cli, err := client.NewEnvClient()
if err != nil {
fmt.Println("Critical - create d... |
package main
import (
"context"
"encoding/json"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"runtime"
"strconv"
"strings"
"time"
"cloud.google.com/go/datastore"
"cloud.google.com/go/storage"
"github.com/gorilla/mux"
"google.golang.org/api/iterator"
)
func backtestHandler(w http.Re... |
package commit
import (
"sort"
"time"
)
type Commit struct {
Revision string `json:"revision"`
Author string `json:"author,omitempty"`
Email string `json:"email,omitempty"`
Date string `json:"date,omitempty"`
Message string `json:"message,omitempty"`
}
func (c Commit) GetDate() *time.Time {
if c.Da... |
package main
import (
"testing"
)
func TestCode(t *testing.T) {
var tests = []struct {
catA int
catB int
mouse int
output string
}{
{
catA: 1,
catB: 2,
mouse: 3,
output: "Cat B",
},
{
catA: 1,
catB: 3,
mouse: 2,
output: "Mouse C",
},
}
for _, test := range ... |
/*
* ALISI client
*
* This is the client API of ALISI. Each device will expose this API in order to be identified by ALISI compliant control units.
*
* API version: 1.0.0
* Contact: matteo.sovilla@studenti.unipd.it
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package ... |
/*
Copyright 2021-2023 ICS-FORTH.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software... |
package middleware
import (
"github.com/dgrijalva/jwt-go"
"github.com/gin-gonic/gin"
"hospital-go/util"
"net/http"
)
type Header struct {
Authorization string `json:"authorization"`
}
func JWT() gin.HandlerFunc {
return func(c *gin.Context) {
header := Header{}
if err := c.ShouldBindHeader(&header); err !=... |
package npilib
import (
"encoding/xml"
c "github.com/arkaev/npilib/commands"
)
type Parser interface {
//Unmarshal node to command pojo
Unmarshal(data []byte) c.NCCCommand
}
type AuthenificateRqParser struct {
Parser
}
//Unmarshal "Authenificate" command
func (h *AuthenificateRqParser) Unmarshal(data []byte) ... |
/*
* Copyright 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 to i... |
package human
type HumanType int
const (
BLACKHUMAN HumanType = iota
YELLOWHUMAN
WHITEHUMAN
FEMALEBLACKHUMAN
MALEBLACKHUMAN
)
func CreateHuman(t HumanType) Human {
switch t {
case BLACKHUMAN:
return &BlackHuman{}
case YELLOWHUMAN:
return &YellowHuman{}
case WHITEHUMAN:
return &WhiteHuman{}
default:
... |
package store
import (
"regexp"
"strings"
"time"
"github.com/kantopark/cronexpr"
"github.com/pkg/errors"
"nidavellir/libs"
)
const (
ScheduleQueued = "QUEUED"
ScheduleRunning = "RUNNING"
ScheduleNoop = "NOOP"
)
type Source struct {
Id int `json:"id"`
Name string `json:"name"`
... |
package client
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
client_models "github.com/garcialuis/ActivityCollector/client/models"
)
// GetActivity fetches and returns an activity with a specified originID from the database
func (activity *ActivityCollector) GetActivity(originID uint64... |
package clippings
import (
"bufio"
"log"
"os"
"strconv"
"strings"
"time"
)
type Clipping struct {
BookTitle string // The book this clipping was taken from
Author string // The author of the book
Type int // The type of clipping (e.g. clipping/bookmark)
Timestamp time.Time // Timestamp o... |
// +build !windows,!darwin
// 29 july 2014
package ui
import (
"fmt"
"reflect"
"unsafe"
"image"
)
// #include "gtk_unix.h"
// extern void goTableModel_toggled(GtkCellRendererToggle *, gchar *, gpointer);
// extern void tableSelectionChanged(GtkTreeSelection *, gpointer);
import "C"
type table struct {
*tableb... |
package http
import (
"context"
"fmt"
"io"
"io/ioutil"
"net"
stdhttp "net/http"
"testing"
"time"
)
func getFreePort(network string) (string, error) {
ln, err := net.Listen(network, "127.0.0.1:")
if err != nil {
return "", err
}
defer ln.Close()
return ln.Addr().String(), nil
}
func TestGraceful(t *tes... |
package inner
import (
"net"
"strconv"
"sync"
"sync/atomic"
"time"
"github.com/qyqx233/go-tunel/lib"
"github.com/qyqx233/go-tunel/lib/proto"
"github.com/rs/zerolog/log"
)
var maxUint63 uint64 = 2<<62 - 1
type transport struct {
minConns int
maxConns int
targetPort int
// targetHost [32]byte
targetH... |
// +build darwin
package easyterm
import (
"golang.org/x/sys/unix"
)
const TCSETATTR = unix.TIOCSETA
const TCGETATTR = unix.TIOCGETA
|
package main
import (
"restic/repository"
"github.com/spf13/cobra"
)
var cmdRebuildIndex = &cobra.Command{
Use: "rebuild-index [flags]",
Short: "build a new index file",
Long: `
The "rebuild-index" command creates a new index by combining the index files
into a new one.
`,
RunE: func(cmd *cobra.Command, args... |
package dns
import (
"context"
"net"
"testing"
)
func TestPacketSession(t *testing.T) {
t.Parallel()
srv := mustServer(localhostZone)
addr, err := net.ResolveTCPAddr("tcp", srv.Addr)
if err != nil {
t.Fatal(err)
}
conn, err := new(Transport).DialAddr(context.Background(), addr)
if err != nil {
t.Fata... |
package usecase
import (
"net"
"strings"
)
func ReplaceLocalhostWithOutboundIP(in string) string {
if strings.Contains(in, "host") {
in = strings.Replace(in, "host", GetOutboundIP().String(), 1)
}
return in
}
func GetOutboundIP() net.IP {
conn, err := net.Dial("udp", "8.8.8.8:80")
if err != nil {
panic(er... |
package handlers
import (
"github.com/hashicorp/go-hclog"
"github.com/milutindzunic/pac-backend/data"
"net/http"
)
type TalksHandler struct {
log hclog.Logger
store data.TalkStore
}
func NewTalksHandler(store data.TalkStore, log hclog.Logger) *TalksHandler {
return &TalksHandler{log, store}
}
func (lh *Talk... |
package osc
import (
"encoding/binary"
"errors"
"time"
)
const (
secondsFrom1900To1970 = 2208988800
bundleIdentifier = "#bundle"
)
var (
errInvalidData = errors.New("invalid data")
)
func getPaddingLength(len int, multipleOf int) int {
return (multipleOf - (len % multipleOf)) % multipleOf
}
func create... |
package stored_responses
import (
"context"
"encoding/json"
"errors"
"testing"
"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/prebid-server/openrtb_ext"
"github.com/stretchr/testify/assert"
)
func TestRemoveImpsWithStoredResponses(t *testing.T) {
bidRespId1 := json.RawMessage(`{"id": "resp_id1"}... |
package jwt
import (
"errors"
"time"
"github.com/dgrijalva/jwt-go"
)
var Singleton *tk
type Claims struct {
PlayLoad string `json:"playLoad"`
jwt.StandardClaims
}
type tk struct {
secret []byte
expiresAt time.Duration
}
func (this tk) TokenCreate(playLoad string) (string, error) {
return jwt.NewWithCla... |
// Copyright (c) Mainflux
// SPDX-License-Identifier: Apache-2.0
package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"
"os/signal"
"strconv"
"syscall"
"time"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
"github.com/jmoiron/sqlx"
"github.com/mainflux/mainflux"
authapi "github.co... |
package main
import "net/http"
func logout(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", `application/json`)
// Parse and check token
token, err := parseToken(r)
if err != nil {
writeError(w, errorToJson(err.Error()), http.StatusBadRequest)
return
}
err = checkJwtToken(token)
if ... |
package supervisor
import (
"context"
"errors"
"fmt"
"sync"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/cloudflare/cloudflared/retry"
tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs"
)
var (
errJWTUnset = errors.New("JWT unset")
)
// reconnectTunnelCredentialManager is... |
package Place
import (
"fmt"
)
type Place struct {
latitude, longtitude float64
Name string
}
func New(latitude, longtitude float64, name string) *Place {
return &Place{saneAngle(0, latitude), saneAngle(0, longtitude), name}
}
func (place *Place) Latitude() float64 {
return place.latitude
}
func (place *Place... |
// 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 utils
import "holdempoker/models"
//WinnerValidator 승자계산
type WinnerValidator struct {
handUtil PokerHandUtil
}
//GetResult 결과를 조회한다.
func (w *WinnerValidator) GetResult(cards []int) models.HandResult {
w.handUtil = PokerHandUtil{}
return w.handUtil.CheckHands(cards)
}
//GetWinner 승자를 조회한다.
func (w *Winn... |
// 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 handler
import (
"log"
"net"
"puck-server/match-server/convert"
"puck-server/match-server/service"
"puck-server/shared-server"
)
func HandleGetLeaderboard(buf []byte, conn net.Conn, serviceList *service.List) {
log.Printf("GETLEADERBOARD received")
// Parse
recvPacket, err := convert.ParseGetLeaderboa... |
package core
var followers = []string{"instagram",
"selenagomez",
"taylorswift",
"arianagrande",
"beyonce",
"kimkardashian",
"cristiano",
"kyliejenner",
"justinbieber",
"therock",
"kendalljenner",
"nickiminaj",
"nike",
"natgeo",
"neymarjr",
"leomessi",
"khloekardashian",
"katyperry",
"mileycyrus",
"... |
package balancer
import (
"testing"
)
func TestBalancer(t *testing.T) {
lb := New(WeightedRoundRobin, nil)
if lb.Name() != "WeightedRoundRobin" {
t.Fatal("balancer.New wrong")
}
lb = New(SmoothWeightedRoundRobin, nil)
if lb.Name() != "SmoothWeightedRoundRobin" {
t.Fatal("balancer.New wrong")
}
lb = New(... |
package red_black
func InsertBalance(t *RBTree) {
parnt := t.Parent
grand := t.Grandparent()
uncle := t.Uncle()
if uncle == nil {
return
}
if uncle.Red {
parnt.Red = false
uncle.Red = false
grand.Red = true
InsertBalance(grand)
return
} else {
switch {
case parnt == grand.Left && t == parnt.Le... |
package main
import (
"fmt"
)
func trocar(p1,p2 int)(segundo int, primeiro int){
segundo = p2
primeiro = p1
return
}
func main(){
r1,r2 := trocar(2,1)
fmt.Println(r1, r2)
} |
package main
import "fmt"
// this is a comment
func main() {
fmt.Println("My Name is, Jagmohan")
} |
package httprequest
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
"syncAgent-go/syncAgent/params"
)
const csrfRecordPath = "./record.txt"
//获取csrf
func csrfGet() (string, error) {
req, err := http.NewRequest("GET", params.TryLoginURL, nil)
if err != nil {
return "", err
}
req.Head... |
package main
import "fmt"
//addNums adds passed in integers, sending the result to the channel
func addNums(num1 int64, num2 int64, ch chan int64) {
res := num1 + num2
// Send result to the channel
ch <- res
}
func main() {
// Create channel
c := make(chan int64)
// Calls go routines, passing in the channe... |
package interaction
import (
"bufio"
"errors"
"fmt"
"os"
"strings"
)
var reader = bufio.NewReader(os.Stdin)
func GetPlayerChoice(isSpecialAttack bool) string {
// infinite loop
for {
userInput, _ := getPlayerInput()
switch userInput {
case "1":
return "ATTACK"
case "2":
return "HEAL"
case "3"... |
// Copyright 2020 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 broadcast
import (
"github.com/iotaledger/goshimmer/plugins/broadcast/server"
"github.com/iotaledger/goshimmer/plugins/config"
flag "github.com/spf13/pflag"
"sync"
"github.com/iotaledger/hive.go/daemon"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledge... |
package v1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type User struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec UserSpec `json:"spe... |
package gonsen
import (
"github.com/mitchellh/packer/common/json"
"io/ioutil"
"net/http"
)
type response struct {
Result []string `json:"result"`
}
func GetProgramNames() ([]string, error) {
res, err := http.Get("http://www.onsen.ag/api/shownMovie/shownMovie.json")
if err != nil {
return nil, err
}
defer r... |
package overmount
import (
"github.com/pkg/errors"
. "gopkg.in/check.v1"
)
func (m *mountSuite) TestTags(c *C) {
_, err := m.Repository.GetTag("test")
c.Assert(errors.Cause(err), Equals, ErrTagDoesNotExist)
err = m.Repository.RemoveTag("test")
c.Assert(errors.Cause(err), Equals, ErrTagDoesNotExist)
_, layer ... |
package odoo
import (
"fmt"
)
// StockLocationRoute represents stock.location.route model.
type StockLocationRoute struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
Active *Bool `xmlrpc:"active,omptempty"`
CategIds *Relation `xmlrpc:"categ_ids,omptempty... |
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"encoding/base64"
"errors"
"fmt"
"io"
"io/ioutil"
mrand "math/rand"
"net/http"
"os"
"strconv"
"strings"
"time"
"github.com/dgrijalva/jwt-go"
"github.com/gin-gonic/gin"
core "github.com/kan-fun/kan-core"
"github.com/kan-fun/kan-server-c... |
package test
import (
"fmt"
"github.com/apitable/apitable-sdks/apitable.go/lib/common"
aterror "github.com/apitable/apitable-sdks/apitable.go/lib/common/error"
"github.com/apitable/apitable-sdks/apitable.go/lib/common/profile"
"github.com/apitable/apitable-sdks/apitable.go/lib/common/util"
apitable "github.com/a... |
package main
import "fmt"
func main() {
// unlike arrays, slices are types only by the elements they
// contain (not the number of elements)
// to create an empty slice with non zero length, use the built-in make
// here we make a slice of strings of length 3 (initially zero valued)
s := make([]s... |
package main
// Transaction type to manage transaction information
type Transaction struct {
Merchant string `json:"merchant"`
Amount float64 `json:"amount"`
Time string `json:"time"`
LastTransaction []Transaction `json:"lastTransaction"`
}
|
package files
import (
"os"
"io/ioutil"
"path/filepath"
)
//返回目录名,文件名
func SplitDirFile(path string) (string, string) {
return filepath.Dir(path), filepath.Base(path)
}
//判断是否存在
func Exist(path string) bool {
_, err := os.Stat(path)
return err != nil
}
//判断是否是文件
func IsFile(path string) bool {
stat, err :=... |
package main
func max(a, b int) int {
if a > b {
return a
}
return b
}
func maxSubArray(nums []int) int {
ans, cur := nums[0], 0
for i := 0 ; i < len(nums) ; i++ {
if cur < 0 {
cur = 0
}
cur = cur + nums[i]
ans = max(ans, cur)
}
return ans... |
package _go
import (
"encoding/json"
"fmt"
"math/rand"
"time"
)
// =============================================================================================================================
// 打印JSON
func PrintJSON(data interface{}) {
js, err := json.MarshalIndent(data, "", " ")
if err != nil {
panic(err... |
/*
Copyright © 2021 Doppler <support@doppler.com>
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 w... |
package parser
import (
"net/http"
"strings"
"golang.org/x/net/html"
)
// GetHyperlinks process a given URL and the request to the UR
// to obtain all the links in it. It does so by tokenizing the
// result <html> body and identifies hyperlinks in it
func GetHyperlinks(BaseURL string, response *http.Response) []s... |
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello Akilan, Welcome to Go!!!")
}
|
package modbusone
import (
"encoding/binary"
"fmt"
)
// DataToBools translates the data part of PDU to []bool dependent on FunctionCode.
func DataToBools(data []byte, count uint16, fc FunctionCode) ([]bool, error) {
if fc == FcWriteSingleCoil {
if len(data) != 2 {
debugf("WriteSingleCoil need 2 bytes data\n")... |
package gdash
import (
"reflect"
"testing"
)
func TestPull(t *testing.T) {
var emptySlice []interface{}
var expectedResult []interface{}
result := Pull(emptySlice, "")
if !reflect.DeepEqual(result, expectedResult) {
t.Fatal("Pull empty slice produce empty slice", result)
}
expectedResult = []interface{}... |
// Copyright (C) 2015-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 th... |
package acrostic
import (
"errors"
log "github.com/sirupsen/logrus"
)
type WordNetSynset struct {
Options *Options
Instance *Instance
}
func NewWordNetSynset(o *Options, i *Instance) *WordNetSynset {
ret := new(WordNetSynset)
ret.Options = o
ret.Instance = i
return ret
}
func (w *WordNetSynset) WordID(a [... |
package ts3
type Client map[string]string
|
package model
import (
"github.com/caos/zitadel/internal/crypto"
caos_errs "github.com/caos/zitadel/internal/errors"
es_models "github.com/caos/zitadel/internal/eventstore/models"
policy_model "github.com/caos/zitadel/internal/policy/model"
"time"
)
type Password struct {
es_models.ObjectRoot
SecretString s... |
package common
import (
"context"
"fmt"
"io"
)
// This file contains types that need to be referenced by both the ./encoding and ./encoding/vX packages.
// It primarily exists here to break dependency loops.
var (
ErrUnsupported = fmt.Errorf("unsupported")
)
// ID in TempoDB
type ID []byte
// Record represents ... |
//
// Observer_test.go
// PureMVC Go Multicore
//
// Copyright(c) 2019 Saad Shams <saad.shams@puremvc.org>
// Your reuse is governed by the Creative Commons Attribution 3.0 License
//
package observer
import (
"github.com/puremvc/puremvc-go-multicore-framework/src/interfaces"
"github.com/puremvc/puremvc-go-mult... |
package policy
import (
"sync"
"testing"
"github.com/stretchr/testify/assert"
)
func TestNopPolicy(t *testing.T) {
p := CombinePolicies()
select {
case <-p.C():
t.Error("should not be able to pull from channel yet")
default:
}
assert.Nil(t, p.Op("foo", Set))
assert.Nil(t, p.Close())
assert.Equal(t, ... |
// Copyright 2021 Adobe. All rights reserved.
// This file is licensed to you 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 applicab... |
package galery
import (
"encoding/json"
"errors"
"net/http"
"os"
"strings"
"github.com/asaskevich/govalidator"
"github.com/juliotorresmoreno/unravel-server/config"
"github.com/juliotorresmoreno/unravel-server/helper"
"github.com/juliotorresmoreno/unravel-server/models"
"github.com/juliotorresmoreno/unravel-... |
package main
// Leetcode 2267. (hard)
func hasValidPath(grid [][]byte) bool {
m, n := len(grid), len(grid[0])
if grid[0][0] == ')' || grid[m-1][n-1] == '(' || (m+n-1)%2 != 0 {
return false
}
dp := make([][][]bool, m)
for i := range dp {
dp[i] = make([][]bool, n)
for j := range dp[i] {
dp[i][j] = make([]... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.