text stringlengths 11 4.05M |
|---|
package util
// Difference finds the difference of given string slice a, from string slice b
// in linear time using map
func Difference(a, b []string) []string {
bContains := make(map[string]bool)
for _, x := range b {
bContains[x] = true
}
diff := make([]string, 0)
for _, x := range a {
if _, ok := bContai... |
package lib
import (
"golang.org/x/crypto/bcrypt"
)
var secret = []byte{1, 2, 1, 2}
func HashPassword(pwd string) (string, error) {
bytes, err := bcrypt.GenerateFromPassword([]byte(pwd), bcrypt.DefaultCost)
if err != nil {
return "", err
}
return string(bytes), nil
}
func AuthenticatePassword(password, hash ... |
package runners
import (
"errors"
"fmt"
"math/rand"
"time"
"github.com/go-resty/resty"
"github.com/golang/glog"
"github.com/hyperpilotio/go-utils/log"
"github.com/hyperpilotio/workload-profiler/clients"
"github.com/hyperpilotio/workload-profiler/jobs"
"github.com/hyperpilotio/workload-profiler/models"
"git... |
package gopenid_test
import (
"fmt"
"github.com/tanopwan/gopenid"
"testing"
"time"
)
// CacheService contains business logic to the domain
type CacheService struct {
data map[string]interface{}
}
// NewCacheService return new object
func NewCacheService() *CacheService {
return &CacheService{
data: make(map[... |
package server
import (
"context"
"net/http"
"go.sancus.dev/cms"
"go.sancus.dev/web"
)
// Server Options
type ServerOption interface {
ApplyOption(*Server) error
}
type ServerOptionFunc func(*Server) error
func (f ServerOptionFunc) ApplyOption(s *Server) error {
return f(s)
}
// Set ViewConfig.GetUser
func ... |
package files
import (
"fmt"
"github.com/Sirupsen/logrus"
"github.com/julienschmidt/httprouter"
"github.com/sanato/sanato-lib/storage"
"io"
"net/http"
"path/filepath"
)
func (api *API) get(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
authRes, err := api.tokenAuth(r, false)
if err != nil {
... |
package main
import (
"fmt"
"syscall/js"
"github.com/adzeitor/stopka"
)
func main() {
machine := stopka.New()
js.Global().Set("stopka", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
machine.Eval(args[0].String())
output := fmt.Sprint(machine.Stack())
if machine.IsHalted() {
output += "( ... |
package main
import (
"log"
"github.com/toy80/native"
)
func appStart() (err error) {
w0 := new(native.NaWindow)
w0.SetSelf(w0)
if err = w0.Init(&native.WindowOptions{
Hints: native.WinHintResizable, // | native.WinHintLimitFPS,
}); err != nil {
log.Println("error: w0.Init:", err)
return
}
w0.SetTitle... |
/*
The MIT License (MIT)
Copyright (c) 2019 Microsoft
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, pu... |
// Copyright 2021 Google 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 ... |
package go_ical
import "strings"
var textEscaper = strings.NewReplacer(
`\`, `\\`,
"\n", `\n`,
`;`, `\;`,
`,`, `\,`,
)
var textUnescaper = strings.NewReplacer(
`\\`, `\`,
`\n`, "\n",
`\N`, "\n",
`\;`, `;`,
`\,`, `,`,
)
func ToText(s string) string {
// process special characters
return textEscaper.Repla... |
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package fcgi
import (
"bytes"
"io"
"os"
"testing"
)
var sizeTests = []struct {
size uint32
bytes []byte
}{
{0, []byte{0x00}},
{127, []byte{0x7F}},
{... |
// Arrays
package main
import "fmt"
func main() {
// declarar un array con 5 strings cada uno, inicializado con 0
var nombres [5]string
// delcarar array con 5 strings, inicializado con valores de string
amigos := [5]string{"Rakel", "isable", "Fernando", "Enrique", "José"}
// Asignar el seundo array al primer... |
package annotated
import hsm "github.com/hhkbp2/go-hsm"
import "log"
const (
StateS0ID string = "s0"
StateS1ID = "s1"
StateS11ID = "s11"
StateS2ID = "s2"
StateS21ID = "s21"
StateS211ID = "s211"
)
func Logln(v ...interface{}) {
log.Println(v...)
}
type VerboseStateHe... |
package syncthing
import (
"os/exec"
"github.com/rumpelsepp/i3gostatus/lib/model"
)
var clickHandlers = &model.ClickHandlers{
HandleRightClick: onRightClick,
HandleLeftClick: onLeftClick,
}
func onRightClick(args *model.ModuleArgs, block *model.I3BarBlock, data interface{}) {
config := data.(*Config)
if isU... |
package event
import (
"testing"
)
func TestNewEvent(t *testing.T) {
event := NewEvent("init", nil)
if _, ok := interface{}(event).(*Event); !ok {
t.Errorf("create event error")
}
if event.Name != "init" {
t.Errorf("bad get name")
}
}
func TestEvent(t *testing.T) {
event := NewEvent("init", nil)
if e... |
package design
import (
. "github.com/goadesign/goa/design"
. "github.com/goadesign/goa/design/apidsl"
)
var _ = Resource("Game", func() {
BasePath("/game")
// Seems that goa doesn't like setting DefaultMedia here at the top-level when the MediaType has multiple Views.
// DefaultMedia(TeamMedia)
Description("De... |
package main
import "fmt"
type Attr struct {
Name string
Age int
}
type AttrEx struct {
Name string
}
type Teacher struct {
Attr
AttrEx
Subject string
}
type Student struct {
Attr
Score int
}
func (a Attr) String() string {
return fmt.Sprintf("%s(%d)", a.Name, a.Age)
}
func (a AttrEx) String() string {... |
package main
import "fmt"
func main() {
var ch chan int
for i := range ch {
fmt.Println(i)
}
}
|
package dht
import (
"testing"
"fmt"
"time"
)
func Test_1(t *testing.T)() {
node0 := makeDHTNode(generateNodeId(), "127.0.0.1", "4242")
node1 := makeDHTNode(generateNodeId(), "127.0.0.1", "4243")
node2 := makeDHTNode(generateNodeId(), "127.0.0.1", "4244")
node3 := makeDHTNode(generateNodeId()... |
package router
import (
_ "yj-app/app/controller/api"
_ "yj-app/app/controller/demo"
"yj-app/app/controller/hello"
_ "yj-app/app/controller/module"
_ "yj-app/app/controller/monitor"
_ "yj-app/app/controller/system"
errorc "yj-app/app/controller/system/error"
"yj-app/app/controller/system/index"
_ "yj-app/app/... |
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright 2020 Broadcom. The term Broadcom refers to Broadcom Inc. and/or //
// its subsidiaries. ... |
package api;
// The definition of the methods used for the API.
import (
"fmt"
"net/http"
"strings"
"github.com/gorilla/mux"
"github.com/eriq-augustine/elfs-api/messages"
"github.com/eriq-augustine/goapi"
"github.com/eriq-augustine/goconfig"
"github.com/eriq-augustine/golog"
"com/eriq-aug... |
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
"github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
"github.com/prometheus/client_golang/prometheus/promhttp"
prommetrics "github.com/slok/go-http-metrics/metrics/prometheus"
prommiddleware "github.com/slok/go-http-metric... |
package solutions
/*
* @lc app=leetcode id=344 lang=golang
*
* [344] Reverse String
*/
/*
Your runtime beats 83.46 % of golang submissions
Your memory usage beats 86.51 % of golang submissions (6.6 MB)
*/
// @lc code=start
func reverseString(s []byte) {
i := 0
j := len(s) - 1
for i < j {
s[i], s[j] = s[j], ... |
package medium739
func dailyTemperatures(T []int) []int {
stack := &stack{}
ans := make([]int, len(T))
for i, v := range T {
for stack.len() != 0 && T[stack.last()] < v {
last := stack.pop()
ans[last] = i - last
}
stack.push(i)
}
return ans
}
type stack []int
func (s *stack) pop() int {
v := (*s)[l... |
package parser_test
import (
"fmt"
"net/http"
"net/http/httptest"
"reflect"
"testing"
"time"
"cloud.google.com/go/bigquery"
"github.com/m-lab/etl/annotation"
p "github.com/m-lab/etl/parser"
"github.com/m-lab/etl/schema"
)
var epoch time.Time = time.Unix(0, 0)
func TestAddGeoDataSSConnSpec(t *testing.T) {... |
package main
import (
"context"
"fmt"
pb "github.com/zdao-pro/sky_blue/examples/proto/testproto"
"github.com/zdao-pro/sky_blue/pkg/log"
"github.com/zdao-pro/sky_blue/pkg/naming/etcd"
"github.com/zdao-pro/sky_blue/pkg/net/rpc/warden"
"github.com/zdao-pro/sky_blue/pkg/net/rpc/warden/resolver"
"go.etcd.io/etcd/c... |
/*
* Auction Bid Tracker
*
* This is an example server for auction bid tracker.
*
* API version: 1.0.0
* Contact: antony.h@riseup.net
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package main
import (
"log"
"net/http"
openapi "github.com/antonyho/go-auction-example/pkg/openapi/go"... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//90. Subsets II
//Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set).
//Note: The solutio... |
// Copyright 2019 Istio 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 i... |
// Copyright Jetstack Ltd. See LICENSE for details.
package read
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"os/user"
"strconv"
vault "github.com/hashicorp/vault/api"
"github.com/sirupsen/logrus"
"github.com/jetstack/vault-helper/pkg/instanceToken"
)
const FlagOutputPath = "dest-pat... |
package config
import (
"sync"
"time"
)
type Manager struct {
userName string // private cookiename
lock sync.Mutex // protects session
provider Provider
maxLifeTime int64
}
type Provider interface {
SessionInit(sid string) (Session, error)
SessionRead(sid string) (Session, error)
SessionDes... |
package store_config
import (
"code.google.com/p/goprotobuf/proto"
"errors"
"fmt"
"log"
"net"
"os"
"strings"
oproto "code.google.com/p/open-instrument/proto"
"regexp"
"time"
)
type config struct {
filename string
config_text string
Config *oproto.StoreConfig
stat os.FileInf... |
package actions
import (
"net/http"
"github.com/nerdynz/datastore"
flow "github.com/nerdynz/flow"
"github.com/nerdynz/schwifty/backend/server/models"
)
// NewMilestone Route
func NewMilestone(w http.ResponseWriter, req *http.Request, ctx *flow.Context, store *datastore.Datastore) {
siteULID, err := ctx.SiteULID... |
package main
import "fmt"
//Go 语言中同时有函数和方法。
//一个方法就是一个包含了接受者的函数,
//接受者可以是命名类型或者结构体类型的一个值或者是一个指针。
//所有给定类型的方法属于该类型的方法集。语法格式如下:
//定义
//func (variable_name variable_data_type) function_name() [return_type]{
/* 函数体*/
//}
/* 定义函数 */
type Circle struct {
radius float64
}
func main() {
var c1 Circle
c1.radius =... |
// We make three passes over the CST in the checker.
//
// 1. Build lexical scopes and memoize semantic data into the CST.
// 2. Type checking and other semantic checks.
// 3. After imports have resolved, semantic checks of imported identifiers.
package checker
import (
"fmt"
"sort"
"github.com/openllb/hlb/diagnos... |
/*
* Copyright 2016-2020 Fraunhofer AISEC
*
* 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 affine
import "github.com/labstack/echo/v4"
func Register(e *echo.Echo) {
group := e.Group("/affine")
group.POST("/encrypt", Encrypt)
group.POST("/decrypt", Decrypt)
}
|
package node
import (
"context"
"github.com/sherifabdlnaby/prism/pkg/job"
"github.com/sherifabdlnaby/prism/pkg/mirror"
"github.com/sherifabdlnaby/prism/pkg/payload"
"github.com/sherifabdlnaby/prism/pkg/response"
)
func (n *Node) sendNextsStream(ctx context.Context, writerCloner mirror.Cloner, data payload.Data)... |
package main
//构造函数
type person struct {
name string
age int
}
func newPerson(name string, age int) person {
return person{
name: name,
age: age,
}
}
|
package day02
import "fmt"
type human struct {
name string
age int
gender bool
}
func StructType() {
tom1 := human{}
var tom2 human
tomPtr := new(human) //为human类型变量分配内存, 并初始化, 返回*S类型指针指向分配的内存
fmt.Println(tom1)
fmt.Println(tom2)
fmt.Printf("%T\t %v\t %#v", tomPtr, tomPtr, tomPtr)
}
|
package models
import "github.com/jinzhu/gorm"
type Poetry struct {
gorm.Model
Title string
Content string
Author string
Remark string
Status int
}
func (Poetry) TableName() string {
return "poetry"
}
|
package main
import (
"math"
"fmt"
)
//Point is a type
//建立一個型別(type)名為Point的結構(struct)
//由結構(struct)組成
//struct內含有x,y二屬性(field),其型別皆為float64
type Point struct {
x float64
y float64
}
//建構一函式(func)作為物件(object)
//函式傳入座標x,y
//用newc函式初始化
//利用私有函式定義x,y的值
//回傳Point屬性
func NewPoint(x,y float64) *Point {
p := new... |
package main
import (
"fmt"
"os"
"text/template"
)
type Book struct {
Title string
Author string
}
func CheckError(err error) {
if err != nil {
fmt.Printf("Error occurred: %v\n", err)
os.Exit(1)
}
}
func main() {
books := []Book{
{Title: "Harry Potter", Author: "J.K. Rowling"},
{Title: "Great Expec... |
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter12/graphql/cards"
"github.com/graphql-go/graphql"
)
func main() {
// grab our schema
schema, err := cards.Setup()
if err != nil {
panic(err)
}
// Query
query := `
{
cards(val... |
package main
import (
"bytes"
"errors"
"fmt"
"os/exec"
)
func ExecInBackgroud(command string) (pid int, output string, err error) {
c := exec.Command("bash", "-c", command)
if c.Stdout != nil {
err = errors.New("exec: Stdout already set")
return
}
if c.Stderr != nil {
err = errors.New("exec: Stderr alr... |
package usecase
import (
"time"
models "github.com/OopsMouse/arbitgo/models"
"github.com/OopsMouse/arbitgo/util"
"github.com/rs/xid"
log "github.com/sirupsen/logrus"
)
func (trader *Trader) runTrader() chan *models.Sequence {
seqch := make(chan *models.Sequence)
go func() {
for {
seq := <-seqch
if tr... |
package main
import (
"github.com/gin-gonic/gin"
. "icxl/Routers"
)
/*
1.注册路由
2.对一个表增删改查
3.docker部署
*/
func main() {
r := gin.Default()
RegisterRoutes(r)
// Listen and serve on 0.0.0.0:8080
r.Run()
}
|
package user
type userService struct {
db UserRepo
}
func NewService() UserService {
return &userService{
db: NewDatabase(),
}
}
type User struct {
UserID int `json:"userID"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Birthdate string `json:"birthdate"`
Location string `j... |
package kvs_test
import (
"io/ioutil"
"strconv"
"github.com/Sirupsen/logrus"
. "github.com/bryanl/dolb/kvs"
"github.com/bryanl/dolb/pkg/app"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Haproxy", func() {
var (
i int
idGen = func() string {
i++
return strconv.Itoa... |
// Conway's Game of Life Imprementation
package main
import (
"bytes"
"fmt"
"math/rand"
"time"
)
type World struct {
s [][]bool
w, h int
}
func NewWorld(w, h int) (World) {
s := make([][]bool, h)
for i := range s {
s[i] = make([]bool, w)
}
return World{s: s, w: w, h: h}
}
func (world *... |
package machinery_test
import (
"fmt"
"testing"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"k8s.io/client-go/tools/clientcmd/api"
)
func TestMachinery(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Machinery Suite")
}
func sampleClusters(ids ...int) *api.Config {
conf := &api.Config{
Cl... |
package chain
import "github.com/lightninglabs/neutrino"
var _ rescanner = (*neutrino.Rescan)(nil)
// rescanner is an interface that abstractly defines the public methods of
// a *neutrino.Rescan. The interface is private because it is only ever
// intended to be implemented by a *neutrino.Rescan.
type rescanner in... |
package statistics_test
import (
"testing"
. "../model"
. "../statistics"
. "gopkg.in/check.v1"
"fmt"
)
func Test(t *testing.T) { TestingT(t) }
type MySuite struct {
board *Board
}
var _ = Suite(&MySuite{})
func (s *MySuite) TestFindHandsOver(c *C) {
s.board = NewDefaultBoard()
handsList := s.board.DealHan... |
package stdutil
import (
"io"
"os"
"runtime/debug"
)
var (
// ShouldTrace sets whether or not PrintErr() should print a stack trace.
ShouldTrace bool
// ErrOutput sets the output PrintErr() should use.
// Defaults to os.Stderr
ErrOutput io.Writer = os.Stderr
// EventPrePrintError is a slice of functions (e... |
package main
import (
"fmt"
"time"
)
func main() {
i := 0
ch := make(chan string, 0) //buffer size is 0
defer func() {
close(ch)
}()
go func() {
fmt.Println("start")
LOOP:
for {
time.Sleep(1*time.Second)
fmt.Println(time.Now().Unix())
i++
select {
case m := <- ch :
fmt.Println(m... |
package web
import (
"fmt"
"github.com/gorilla/mux"
"github.com/rebelit/rpIoT/config"
"net/http"
)
func NewRouter() *mux.Router {
router := mux.NewRouter().StrictSlash(true)
for _, route := range routes {
router.
Methods(route.Method).
Path(route.Pattern).
Name(route.Name).
Handler(route.HandlerF... |
package observerPattern
import (
"design-patterns-go/observerPattern/event"
"design-patterns-go/observerPattern/notifier"
"design-patterns-go/observerPattern/observer"
"fmt"
)
type ObserverPattern interface {
Run()
}
type observerPattern struct {
observerPattern ObserverPattern
}
func NewObserver() observerPa... |
package getter
import (
"context"
"errors"
notifications "gx/ipfs/QmYJ48z7NEzo3u2yCvUvNtBQ7wJWd5dX2nxxc7FeA6nHq1/go-bitswap/notifications"
logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log"
cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
blockstore "gx/ipfs/QmS2aqUZLJp8... |
package service
import (
"bytes"
"fmt"
"github.com/chanxuehong/wechat/mp/core"
"github.com/chanxuehong/wechat/mp/material"
"html/template"
"strconv"
"strings"
"tesou.io/platform/brush-parent/brush-api/common/base"
"tesou.io/platform/brush-parent/brush-api/module/match/pojo"
"tesou.io/platform/brush-parent/br... |
package manager
import (
"context"
"errors"
"testing"
"time"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"golang.org/x/oauth2"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb"
"g... |
package isaac
import "time"
const (
variablesBasePath = "/api/v1/variables"
)
type VariablesService interface {
Add(NewVariable) (Variable, error)
Get(ID) (Variable, error)
List() ([]Variable, error)
Remove(Variable) error
Update(Variable) (Variable, error)
UpdateValue(Variable, string) (Variable, error)
}
t... |
// okaq web server
// horse swan
// AQ <aq@okaq.com>
// 2018-01-06
package main
import (
"fmt"
"net/http"
"time"
)
const (
INDEX = "zwai.html"
)
func AwaiHandler(w http.ResponseWriter, r *http.Request) {
fmt.Println(r)
http.ServeFile(w,r,INDEX)
}
func main() {
fmt.Printf("okaq equus star... |
package controllers
import (
"net/http"
"strconv"
"github.com/labstack/echo"
"github.com/marcelors/curso/usuarios/models"
)
//Home is page initial the application
func Home(c echo.Context) error {
var users []models.User
if err := models.UserModel.Find().All(&users); err != nil {
return c.JSON(http.StatusBa... |
package handlers
import (
"net/http"
"github.com/chisty/microservice_go/data"
)
// Create handles post request
func (p *Products) Create(rw http.ResponseWriter, r *http.Request) {
p.l.Println("Handle Post Request")
prod := r.Context().Value(KeyProduct{}).(data.Product)
p.l.Println("Running prod: "... |
// Copyright (c) 2019 bketelsen
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
package lxd
import (
"fmt"
"github.com/bketelsen/libgo/events"
"github.com/lxc/lxd/client"
client "github.com/lxc/lxd/client"
"github.com/lxc/lxd/shared/api"
"github.com/lxc/lxd/shared/i... |
package flow
import (
"context"
"time"
"github.com/direktiv/direktiv/pkg/flow/bytedata"
"github.com/direktiv/direktiv/pkg/flow/grpc"
"github.com/direktiv/direktiv/pkg/refactor/core"
"github.com/google/uuid"
"google.golang.org/protobuf/types/known/emptypb"
)
func (flow *flow) Secrets(ctx context.Context, req *... |
package oauth2
import "context"
// Access token interface.
type AccessTokenRepositoryInterface interface {
// Create a new access token
GetNewToken(ctx context.Context,ce ClientEntityInterface, scopes []ScopeEntityInterface, userIdentifier string) AccessTokenEntityInterface
// Persists a new access token to perman... |
package db
import (
"testing"
"github.com/GoAdminGroup/go-admin/modules/config"
_ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mssql"
)
var driverTestMssqlConn Connection
func InitMssql() {
driverTestMssqlConn = testConn(DriverMssql, config.Database{
Host: "127.0.0.1",
Port: "1433",
User: "sa",
... |
package models
import "time"
type Alert struct {
ID string
Description string
DateAdd time.Time
}
|
package main
import (
"fmt"
"io/ioutil"
"net/http"
"github.com/PuerkitoBio/goquery"
"github.com/stcrestrada/gogo"
)
func SimpleAsyncGoroutines() {
// Launched in another goroutine (not blocking)
proc := gogo.Go(func() (interface{}, error) {
return http.Get("https://news.ycombinator.com/")
})
// Launch mu... |
package cloudconfig
const DecryptKeysAssetsService = `
[Unit]
Description=Decrypt Secret Keys
Before=k8s-kubelet.service
After=wait-for-domains.service
Requires=wait-for-domains.service
[Service]
Type=oneshot
ExecStart=/opt/bin/decrypt-keys-assets
[Install]
WantedBy=multi-user.target
`
|
/*
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 collector_test
import (
"context"
"testing"
"github.com/fabric8-services/fabric8-notification/collector"
"github.com/goadesign/goa/uuid"
"github.com/stretchr/testify/assert"
)
func TestUser(t *testing.T) {
_, authClient := createClient(t)
uID, _ := uuid.FromString("3383826c-51e4-401b-9ccd-b898f7e2397d... |
package mappers
import (
"fmt"
"github.com/vfreex/gones/pkg/emulator/memory"
"github.com/vfreex/gones/pkg/emulator/rom/ines"
)
/*
http://wiki.nesdev.com/w/index.php/INES_Mapper_003
iNES Mapper 003 is used to designate the CNROM board,
generalized to support up to 256 banks (2048 KiB) of CHR ROM.
PRG ROM size: 16... |
package main
import (
"fmt"
"strconv"
)
func main() {
red := uint64(0)
red = uint64(red)
green := uint64(0)
green = uint64(green)
blue := uint64(0)
blue = uint64(blue)
var finalArr []int
//colors := []string{"A0FC77", "90CACA"}
for i, x := range colors {
red, _ := strconv.ParseUint(x[0:2], 16, 32)
... |
package develop
import (
"net/http"
"github.com/gorilla/mux"
)
type developService struct {
handler http.Handler
baseURI string
}
func New() *developService {
service := &developService{}
service.baseURI = "/develop"
router := mux.NewRouter()
router.HandleFunc(service.baseURI+"/ping/", service.pingHandler)... |
package elements
import (
"fmt"
"math/rand"
"strings"
"github.com/Nv7-Github/Nv7Haven/eod/types"
"github.com/Nv7-Github/Nv7Haven/eod/util"
"github.com/bwmarrin/discordgo"
)
var ideaCmp = discordgo.ActionsRow{
Components: []discordgo.MessageComponent{
discordgo.Button{
Label: "New Idea",
Style: d... |
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use ... |
package main
import (
"fmt"
"os"
"github.com/kentakozuka/software-timeline/pkg/gateway/cmd"
)
func main() {
command := cmd.NewDefaultGatewayCommand()
if err := command.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}
|
package mut
type Handler interface {
// OnConnect : you may want add some UserData here
OnConnect(c *Conn)
// OnMessage only available while async mode
OnMessage(c *Conn, p Packet)
OnClose(c *Conn)
OnError(c *Conn, err error)
}
type HandlerSkeleton struct {
Handler
_OnConnect func(c *Conn)
_OnMessage func(c... |
package queueinformer
import (
"math"
"math/rand"
"reflect"
"testing"
"testing/quick"
"time"
"github.com/stretchr/testify/require"
)
type fakeFloat64er float64
func (f fakeFloat64er) Float64() float64 {
return float64(f)
}
func TestResyncWithJitter(t *testing.T) {
type args struct {
resyncPeriod time.Du... |
// Copyright 2022 PingCAP, Inc. Licensed under Apache-2.0.
package iter_test
import (
"context"
"errors"
"sync/atomic"
"testing"
"time"
"github.com/pingcap/tidb/br/pkg/utils/iter"
"github.com/stretchr/testify/require"
)
func TestParTrans(t *testing.T) {
items := iter.OfRange(0, 200)
mapped := iter.Transfor... |
package structs
type Department struct {
Id int `json:"department_id" query:"departmentid" db:"department_id"`
Code string `json:"department_code" query:"departmentcode" db:"department_code"`
Name string `json:"department_name" query:"departmentname" db:"department_name"`
Active bool `json:"active" qu... |
package base
import (
"fmt"
"log"
"log/syslog"
"os"
"github.com/golang/glog"
)
type LogfFunc func(format string, v ...interface{})
type LoggingAdapter struct {
Debugf, Infof, Warnf, Errorf, Fatalf, Panicf LogfFunc
}
var (
LogAdapter = &LoggingAdapter{
Debugf: func(format string, v ...interface{}) { log.Pr... |
package chargen
var (
hairColors = []string{
"black",
"brown",
"auburn",
"blonde",
"red",
"jet black",
"dark brown",
"light brown",
"white",
"grey",
}
hairStyles = []string{
"bald",
"short-cropped",
"shoulder-length",
"long",
"spikey",
"wavey",
"cornrows",
"bobbed",
"ponytail"... |
package sorting
import (
"fmt"
"github.com/s4rvesh/DSinGo/DS-Algorithms/output"
)
//Bubble sort algorithm implementation
func Bubble(array []int) []int {
fmt.Println("Sorting using Bubble Sort")
for i := len(array) - 1; i > 1; i-- {
for x := 0; x < i; x++ {
y := x + 1
if array[x] > array[y] {
ar... |
// Copyright 2017 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 utils
//Compute 两位运算
func Compute(a int, opt string, b int) int {
switch opt {
case "-":
return sub(a, b)
case "*":
return mul(a, b)
case "/":
return div(a, b)
default:
return add(a, b)
}
}
//真正的运算方法
func add(a int, b int) int {
return a + b
}
func sub(a int, b int) int {
return a - b
}
func m... |
package cmd
import (
"os"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
var OptHost string
func init() {
RootCmd.PersistentFlags().StringVarP(&OptHost,
"host", "H",
"/run/conmand.sock",
"Daemon socket to connect")
}
var RootCmd = &cobra.Command{
Use: "conmanctl",
Short: "conmanctl - CLI too... |
package main
import(
"fmt"
"encoding/json"
"strconv"
"net/http"
"io/ioutil"
"./user"
gofpdf "github.com/jung-kurt/gofpdf"
)
func check(err error) {
if err != nil {
panic(err)
}
}
func main() {
var users []user.User
url := "https://golang-jsonservice.herokuapp.com/us... |
package handler_test
import (
"net/http"
"testing"
"github.com/teejays/clog"
"github.com/teejays/n-factor-vault/backend/library/go-api/apitest"
"github.com/teejays/n-factor-vault/backend/library/orm"
"github.com/teejays/n-factor-vault/backend/src/auth"
"github.com/teejays/n-factor-vault/backend/src/server/ha... |
package main
import (
"fmt"
"os"
"github.com/gokitter/kitter/client"
"github.com/gokitter/kitter/server"
)
func main() {
// Set up a connection to the server.
if os.Args[2] == "server" {
server.StartRPCServer(os.Args[1])
} else if os.Args[2] == "receive" {
c := clientfactory.Create(os.Args[1])
c.ReadStr... |
package api
import (
"net/http"
service "github.com/allvisss/ECC_service/services/keygen"
ecies "github.com/ecies/go"
"github.com/gin-gonic/gin"
)
type KeyGenerateHandler struct {
}
func NewKeyGenerateHandler(r *gin.Engine) {
handler := &KeyGenerateHandler{}
v1 := r.Group("/v1")
{
v1.GET("/keygen", handler... |
package webhook
import (
"context"
"crypto/sha256"
"encoding/json"
"io/ioutil"
"net/http"
"reflect"
"strings"
"github.com/xmwilldo/edge-health/cmd/webhook/app/options"
"github.com/xmwilldo/edge-health/pkg/util"
"github.com/ghodss/yaml"
admissionv1 "k8s.io/api/admission/v1"
admissionregistrationv1beta1 "k... |
package main
import (
"log"
"net/http"
"time"
"github.com/julienschmidt/httprouter"
)
// Logger wraps the handler function with basic log message.
func Logger(fn func(w http.ResponseWriter, r *http.Request, param httprouter.Params)) func(w http.ResponseWriter, r *http.Request, param httprouter.Params) {
return ... |
package use
import (
"github.com/devspace-cloud/devspace/cmd/flags"
"github.com/devspace-cloud/devspace/pkg/util/factory"
"github.com/spf13/cobra"
)
// NewUseCmd creates a new cobra command for the use sub command
func NewUseCmd(f factory.Factory, globalFlags *flags.GlobalFlags) *cobra.Command {
useCmd := &cobra.... |
func pow(x int64, y int64) {
if y == 0 {
return 1;
} else {
return x * pow(x, y - 1)
}
} |
func rand10() int {
key:=100
for key>40{
key = 7*(rand7()-1)+rand7()
}
return key%10+1
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.