text stringlengths 11 4.05M |
|---|
package sweep
// ResponseHeader represents a command response header.
type ResponseHeader struct {
Cmd [2]byte
CmdStatus Int2
CmdSum byte
}
// CommandParamPacket ...
type CommandParamPacket struct {
Cmd [2]byte
CmdParam [2]byte
}
// ResponseParamA represents the first part of a response parameter ... |
package camt053
import (
"bufio"
"os"
"testing"
)
func TestRead(t *testing.T) {
f, e := os.Open("./CAMT053.xml")
if e != nil {
t.Fatal(e)
}
buf := bufio.NewReader(f)
if e := Read(buf, func(head GrpHdr, stmt Stmt) error {
/*for _, ntry := range stmt.Ntry {
if ntry.NtryDtls.TxDtls.BkTxCd.Prtry.Cd == PAY... |
package main
import (
"github.com/gorilla/websocket"
"context"
"net/http"
"encoding/json"
mon "part5/internal/monitor"
"io/ioutil"
"part5/internal/incident"
"log"
)
var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
CheckOrigin: func(_ *http.Request) bool {
return true
}... |
package main
import (
"fmt"
"os"
)
func main() {
if len(os.Args) != 3 {
fmt.Println("Usage: dldist string1 string2")
fmt.Println(" The program will compute the Damerau-Levenshtein distance between string1 and string2.")
return
}
dist := DLDist(os.Args[1], os.Args[2])
fmt.Println(dist)
}
|
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package enterprise
import (
"context"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/local/arc"
"chromiumos/tast/local/arc/arcent"
"chromiumos/tast/local/arc/plays... |
package config
import (
"encoding/json"
"log"
"os"
)
// Save save current status and config to file
func Save() {
SaveStatus()
SaveConfig()
}
// SaveStatus save and indent Status to status.json
func SaveStatus() {
b, err := json.MarshalIndent(status, "", " ")
if err != nil {
log.Println("Failed to save sta... |
// 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 bitmap
import (
"errors"
"io"
)
var (
errOutOfRange = errors.New("out of range")
errAssignSize = errors.New("size not match")
)
type Bitmap struct {
val []byte
size int
}
func NewEmptyBitmap(size int) *Bitmap {
if size == 0 {
return new(Bitmap)
}
return &Bitmap{
val: make([]byte, (size-1)/8+1... |
// 06 Pivot root
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {
switch os.Args[1] {
case "run":
run()
case "child":
child()
default:
panic(fmt.Sprintf("Unknow command %s", os.Args[1]))
}
}
func run() {
cmd := exec.Command("/proc/self/exe", append([]string{"child"}, os.Args[2:].... |
package mapreduce
//
// any additional state that you want to add to type WorkerInfo
//
type WorkerInfoImpl struct {
//status bool // 1 means busy, 0 means available
}
//
// run the MapReduce job across all the workers
//
func (mr *MapReduce) RunMasterImpl() {
mr.Workers = make(map[string]*WorkerInfo)
Mapjob ... |
package main
import "fmt"
type Number struct {
a int
b int
}
func (num *Number)Multi() int {
return num.a*num.b
}
func main() {
num:=Number{
a: 2,
b: 6,
}
fmt.Println(num.Multi())
} |
// Copyright 2021 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... |
package ship
import (
"bufio"
"bytes"
"encoding/json"
"fmt"
"html/template"
"io"
"io/ioutil"
"log"
"net/http"
"os"
"path"
"strings"
"sync"
"time"
)
type Server struct {
Host string
Root string
Builds string
Builders map[string]*Builder
Requests map[string]*Requests
apps map[string]map[s... |
package test
import "testing"
//运行前初始化,只运行一次
func TestMain(m *testing.M) {
println("start")
m.Run()
println("end")
}
//测试普通函数和方法
func Test1(t *testing.T) {
println("test1")
}
func Test2(t *testing.T) {
println("test2")
}
func Test3(t *testing.T) {
print(testing.Short())
} |
package interfaces
import (
repo "github.com/salihkemaloglu/gignoxqc-beta-001/repositories"
)
//IUserRepository ..
type IUserRepository interface {
Login() (*repo.User, error)
}
|
package main
import "fmt"
// Channels are the pipes that connect concurrent goroutines.
func main() {
message := make(chan string)
//启动一个goroutine
go func() {
//Send a value into a channel using the channel <- syntax.
//消息进入通道
message <- "ping"
}()
//消息出通道 传给message
msg := <-message
fmt.Println(msg)
}
|
// Copyright 2017 Zhang Peihao <zhangpeihao@gmail.com>
package httpapi
import (
"io/ioutil"
"net/http"
"strings"
"github.com/golang/glog"
"github.com/zhangpeihao/shutdown"
"github.com/zhangpeihao/zim/pkg/broker"
"github.com/zhangpeihao/zim/pkg/protocol"
"github.com/zhangpeihao/zim/pkg/util"
)
// Subscribe 订... |
package clientkube
import (
"context"
"log"
"os"
"testing"
"github.com/go-logr/stdr"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/runtime/schema"
"github.com/bryanl/clientkube/pkg/cluster"
"github.com/bryanl/clientkube/pkg/mocks"
)
func TestMemoryStoreInfo... |
package main
import "fmt"
func main(){
/*
while
i := 0
for i < 10 {
fmt.Println("E aew rapaziada", i)
i = i + 1
}
*/
// for
/* for i := 0; i <10; i++ {
fmt.Println("E aew rapaziada", i)
}
*/
}
|
package configuration
import (
"os"
"strings"
"time"
errs "github.com/pkg/errors"
"github.com/spf13/viper"
)
const (
// Constants for viper variable names. Will be used to set
// default values as well as to get each value
varCleanTestDataEnabled = "clean.test.data"
varDBLogsEnabled = "enable.db.logs... |
package colour
import (
"testing"
)
func TestColour(t *testing.T) {
colour := New(-0.5, 0.4, 1.7)
if colour.Red != -0.5 {
t.Error("Could not access the Red attribute of Colour.")
}
if colour.Green != 0.4 {
t.Error("Could not access the Red attribute of Colour.")
}
if colour.Blue != 1.7 {
t.Error("Could n... |
// Copyright 2021 Andrew Werner.
//
// 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 ... |
package evaluator
import (
"fmt"
"github.com/grossamos/jam0001/shared"
)
type MissingArgumentError struct {
message string
pos shared.Position
}
func (mae *MissingArgumentError) Error() string {
return fmt.Sprintf("MissingArgumentError (at line %d): %s", mae.pos.Line, mae.message)
}
type TypeError struct ... |
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package taskswitchcuj
import (
"context"
"chromiumos/tast/errors"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/chrome/ash"
"chromiumos/tast/local/chrome/brows... |
package http
import (
"marketplace/accounts/domain"
"marketplace/accounts/internal/usecase"
"net/http"
"strconv"
"github.com/gin-gonic/gin"
"github.com/go-pg/pg/v10"
"github.com/sirupsen/logrus"
)
type GetUserByIdResponse struct {
Id int64 `json:"id"`
Email string `json:"email"`
Usern... |
package main
import (
"database/sql"
"encoding/json"
"net/http"
"strings"
"time"
)
// Configures the serve mux for the application.
func (app *Application) setupRoutes() {
app.Routes = http.NewServeMux()
app.Routes.Handle("/api/newapikey/",
addHeaders(http.HandlerFunc(app.newAPIKey)))
app.Routes.Handle("/... |
package leetcode_go
func findTilt(root *TreeNode) int {
res := 0
helperP563(root, &res)
return res
}
func helperP563(root *TreeNode, tiltSum *int) int {
if root == nil {
return 0
}
leftSum := helperP563(root.Left, tiltSum)
rightSum := helperP563(root.Right, tiltSum)
tilt := leftSum - rightSum
if tilt < 0 {... |
package main
import (
"os"
"path/filepath"
"github.com/shyang107/paw"
"github.com/shyang107/paw/filetree"
"github.com/urfave/cli"
)
func checkArgs(c *cli.Context, pdopt *filetree.PrintDirOption) {
switch c.NArg() {
case 0:
lg.WithField("arg", c.Args().Get(0)).Trace("no argument")
path, err := filepath.Ab... |
package chpool
import (
"context"
"github.com/vahid-sohrabloo/chconn/v2"
)
type insertStmt struct {
chconn.InsertStmt
conn Conn
}
func (s *insertStmt) Flush(ctx context.Context) error {
if s.conn == nil {
return nil
}
defer s.conn.Release()
return s.InsertStmt.Flush(ctx)
}
func (s *insertStmt) Close() {
... |
// project euler (projecteuler.net) problem 1
// solution by Kevin Retzke (retzkek@gmail.com) April 2012
package main
import (
"fmt"
)
// Natmult computes the sum of all multiples of the given bases that are
// below max.
func natmult(bases []int, max int) int {
result := 0
for i := 0; i < max; i++ {
for _, b :=... |
package biz
import (
"context"
pb "edu/api/sys/v1"
"edu/service/sys/internal/model"
"github.com/golang/protobuf/ptypes"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/timestamppb"
)
func (uc *AdminUsecase) ListPost(c context.Context, token string, req *pb.ListPostReques... |
package utils
func Plural(n int32) string {
if n > 1 {
return "s"
}
return ""
}
|
/*
Copyright 2015 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(
"net/http"
"html/template"
"os"
"path"
"fmt"
"math/rand"
)
//global variables
var Israndom bool = true
var Masterindex int = 0
type Question struct {
Thequestion string
}
// func InitializeVariables {
//@ToDo read text file and initialize variables
// Read a slice from a jas... |
package forum
import (
potato "github.com/rise-worlds/potato-go"
)
// NewVote is an action representing a simple vote to be broadcast
// through the chain network.
func NewVote(voter potato.AccountName, proposalName potato.Name, voteValue uint8, voteJSON string) *potato.Action {
a := &potato.Action{
Account: Foru... |
package main
import (
"fmt"
"net/http"
"github.com/OrbitalbooKING/booKING/server/controllers"
"github.com/gin-gonic/gin"
"github.com/OrbitalbooKING/booKING/server/services"
)
func main() {
r := gin.Default()
http.Handle("/", http.FileServer(http.Dir("./build")))
if err := services.ConnectDataBase(); err != ... |
package middleware
import (
"net/http"
"net/http/httputil"
"fmt"
"context"
"encoding/json"
)
type AuthResponse struct {
UserId string `json:"user_id"`
}
func AuthMiddleWare(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter,r *http.Request) {
clie... |
package main
import (
"bufio"
"fmt"
"log"
"os"
"sort"
"strings"
)
func roadTrip(s string) string {
var v, c int
t := strings.Split(s, ";")
l, m := make([]int, len(t)-1), make([]string, len(t)-1)
for i := range l {
u := strings.Split(t[i], ",")
fmt.Sscan(u[1], &v)
l[i] = v
}
sort.Ints(l)
for i := ra... |
package util
import "encoding/json"
import "net/http"
// Response is a struct to define body of http response
type ResponseType struct {
Erro bool `json:"erro"`
Mensagem string `json:"mensagem"`
Dados interface{} `json:"dados"`
}
//Creates a new response body to answer the request
func NewRe... |
package closureBase
import "fmt"
//闭包复制的是原对象指针
func a() func() int {
i := 0
b := func() int {
i++
fmt.Println(i)
return i
}
return b
}
func AClosure() {
var c = a()
c()
c()
c()
var c2 = a()
c2()
c2()
c2()
}
func Test() func() {
x := 100
fmt.Printf("fis - > x (%p) = %d\n", &x, x)
return func() ... |
package mondohttp
import (
"net/url"
"strconv"
)
// ProductionAPI is the base URL of Mondo's production API.
const ProductionAPI string = "https://api.getmondo.co.uk/"
// StagingAPI is the usual base URL of Mondo's staging API (commonly available
// during hackathons).
const StagingAPI string = "https://staging-ap... |
// +build !linux !static
package cgo
// #cgo LDFLAGS: -lrocksdb -lstdc++ -lm -lz -ldl
import "C"
|
package individualparsers
import (
"strings"
)
type PowershellKeyword struct{}
func (b PowershellKeyword) Match(content []byte) (bool, error) {
// powershell contained within paste
lowerContent := strings.ToLower(string(content))
normalContent := strings.Replace(lowerContent, "^", "", -1)
if strings.Contains(no... |
package server
import (
"strconv"
"strings"
"net/http"
"encoding/json"
"github.com/google/uuid"
"github.com/gorilla/mux"
"toggl-card/internal/card"
"toggl-card/internal/deck"
)
type api struct {
router http.Handler
}
// Server is the interface that wraps the router method
type Server interface {
Router() h... |
package server
import (
pb "github.com/1851616111/xchain/pkg/protos"
sliceutil "github.com/1851616111/xchain/pkg/util/slice"
"log"
"os"
)
var (
endPointLog = log.New(os.Stderr, "[Event]", log.LstdFlags)
)
func newEndPointManager() *EndPointManager {
m := new(EndPointManager)
m.IDToAddress = map[string]string{... |
package resolver
import (
"fmt"
"sort"
"github.com/aws/aws-sdk-go/aws"
"github.com/opsee/basic/schema"
opsee_aws_cloudwatch "github.com/opsee/basic/schema/aws/cloudwatch"
opsee "github.com/opsee/basic/service"
opsee_types "github.com/opsee/protobuf/opseeproto/types"
"golang.org/x/net/context"
)
type metricLi... |
// Copyright 2018 Aleksandr Demakin. All rights reserved.
package pjw
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestPJW(t *testing.T) {
const (
hello = "Hello"
world = ", world!"
)
r := require.New(t)
pjw := New()
r.Equal(4, pjw.Size())
r.Equal(1, pjw.BlockSize())
r.Equal(uint32(0... |
package solutions
func buildTree(preorder []int, inorder []int) *TreeNode {
if len(preorder) == 0 || len(inorder) == 0 {
return nil
}
position := -1
for i, number := range inorder {
if preorder[0] == number {
position = i
}
}
return &TreeNode{
preo... |
package main
import (
"fmt"
"math"
// "encoding/hex"
"encoding/binary"
"go.bug.st/serial.v1"
// "go.bug.st/serial.v1/enumerator"
// "github.com/bugst/go-serial"
// "github.com/bugst/go-serial/enumerator"
)
// 全局变量,用来保存选定的串口
var g_port_lpms9 serial.Port
func serial_lpms9_open(name string) (serial.Port, error)... |
package main
import "fmt"
func main() {
v := 43 // v contains int 43
w := v // w contains int 43
vw := &v // vw contains address of v
ww := &w // ww contains address of w
wv := *&v // wv contains int 43
*vw = 57 // changes v and wv to int 57, but w remains containing int 43
fmt.Println("'v'\t", v)
fm... |
// Package intl provides utilties for internationalization.
package intl
import "strings"
// An L10NString is a string which should be localized. Defined as its
// own type so that you can't pass a variable of type string as the
// fmt argument to L10N.Fmt, but you can still pass a string literal.
type L10NString str... |
package ecs
import "fmt"
// Entity is a reference to an entity in a Core
type Entity struct {
co *Core
id EntityID
}
// NilEntity is the zero of Entity, representing "no entity, in no Core".
var NilEntity = Entity{}
func (ent Entity) String() string {
if ent.co == nil {
return fmt.Sprintf("Nil<>[%v]", ent.id)
... |
package main
import (
"log"
"net/http"
"github.com/16francs/examin_go/config"
"github.com/16francs/examin_go/infrastructure/router"
)
func main() {
// ログ出力設定
config.Logger()
// 環境変数
env, err := config.LoadEnv()
if err != nil {
log.Fatalf("alert: %s", err)
}
// 起動コマンド
router := router.Router()
if err... |
package openrtb_ext
// ExtImpAvocet defines the contract for bidrequest.imp[i].ext.prebid.bidder.avocet
type ExtImpAvocet struct {
Placement string `json:"placement,omitempty"`
PlacementCode string `json:"placement_code,omitempty"`
}
|
package main
import "sort"
// Leetcode m16.24. (medium)
func pairSums(nums []int, target int) (res [][]int) {
sort.Slice(nums, func(i, j int) bool {
return nums[i] < nums[j]
})
i, j := 0, len(nums)-1
for i < j {
if nums[i]+nums[j] == target {
res = append(res, []int{nums[i], nums[j]})
i++
j--
} el... |
package node
type Wait struct {
c chan *Resp
}
func NewWait() *Wait {
return &Wait{
c: make(chan *Resp),
}
}
func (w *Wait) Close(resp *Resp) {
for {
select {
case w.c <- resp:
continue
default:
return
}
}
}
func (w *Wait) Wait() *Resp {
r := <-w.c
return r
}
|
package repository
import (
"encoding/json"
"github.com/yerlan-tleubekov/go-redis/internal/models"
)
type IUser interface {
CreateUser(*models.User) error
GetUser(string) (*models.User, error)
}
func (repo *Repository) CreateUser(user *models.User) error {
userJSON, err := json.Marshal(user)
if err != nil {
... |
package helper
import (
"flag"
"fmt"
"log"
"path/filepath"
"regexp"
)
type Input struct {
inPutFile string
outPutFile string
}
func (i *Input) ProcessArgv() {
// Get argv from flag
savedFile := flag.String("s", "dir", "-s saved file")
flag.Parse()
inputs := flag.Args()
// Check main input
if len(input... |
package main
import (
"fmt"
)
type rectangle struct {
width, height int
}
func (r *rectangle) area() int {
return r.width * r.height
}
func (r rectangle) circumference() int {
return 2*r.width + 2*r.height
}
func main() {
r := rectangle{width: 10, height: 5}
fmt.Println("area: ", r.area())
fmt.Println("cir... |
package connection
import (
"sync"
"time"
"github.com/multivactech/MultiVAC/logger"
"github.com/multivactech/MultiVAC/model/shard"
"github.com/multivactech/MultiVAC/model/wire"
"github.com/multivactech/MultiVAC/p2p/peer"
)
// Multiplexer defines the data structure for handler.
type Multiplexer struct {
msgHan... |
package frequency
// Queries processes the list of queries provided
func Queries(q [][]int32) []int32 {
var res []int32
var counts = map[int32]int32{}
for _, v := range q {
switch v[0] {
case 1:
// Insert statement
if _, ok := counts[v[1]]; ok {
counts[v[1]]++
} else {
counts[v[1]] = 1
}
c... |
package main
import "fmt"
func main() {
// 创建一个整型切片,并赋值
slice := []int{10, 20, 30, 40}
// 迭代每一个元素,并显示其值
//Index: 0 Value: 10
//Index: 1 Value: 20
//Index: 2 Value: 30
//Index: 3 Value: 40
for index, value := range slice {
fmt.Printf("Index: %d Value: %d\n", index, value)
}
}
|
/*
Copyright 2023 Gravitational, 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 in writin... |
//目前的jsonrpc库是基于tcp协议实现的,暂时不支持使用http进行数据传输
package main
import (
"./rpcObjects"
"io"
"log"
"net"
"net/rpc"
"net/rpc/jsonrpc"
"os"
)
func main() {
calc := new(rpcObjects.Args) // 服务器创建一个用于计算的对象
_ = rpc.Register(calc) // 注册rpc服务
listener, e := net.Listen("tcp", "localhost:1234") // 开启监听
if e != nil... |
package e2e
import (
"context"
"fmt"
"log"
"testing"
"time"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
nc "github.com/openshift/windows-machine-config-operator/pkg/controlle... |
package main
import (
"fmt"
"gin-use/bootstrap"
"gin-use/configs"
_ "gin-use/docs"
"gin-use/src/global"
"gin-use/src/routes"
"github.com/gin-gonic/gin"
_ "github.com/joho/godotenv/autoload"
)
var (
r = gin.Default()
)
// @title swagger 接口文档
// @version 2.0
// @description
// @contact.name
// @contact.url
/... |
package health
import "time"
type Controller struct {
states map[string]WatchedState // A dynamic state under a name. (eg: states["twilio"] = &twilio.State)
}
func NewController() *Controller {
m := make(map[string]WatchedState)
return &Controller{m}
}
func (c *Controller) Register(name string, value *string) {
... |
package main
import "testing"
func TestCalculateSystemEnergy(t *testing.T) {
actual := calculateSystemEnergy([]string{
"<x=-1, y=0, z=2>",
"<x=2, y=-10, z=-7>",
"<x=4, y=-8, z=8>",
"<x=3, y=5, z=-1>",
}, 10)
expected := 179
if expected != actual {
t.Errorf("Expected energy %v, but actua... |
package metal
import (
"fmt"
// M "github.com/ionous/sashimi/compiler/model"
"github.com/ionous/sashimi/meta"
"github.com/ionous/sashimi/util/errutil"
"github.com/ionous/sashimi/util/ident"
)
var _ = fmt.Println
type objectList struct {
panicValue
targetProp ident.Id
objs []ident.Id
}
// the many side... |
package store
import (
"log"
"github.com/coreos/etcd/store/streams"
"sync"
"strconv"
"strings"
"fmt"
)
const PREFIX string = "/2/"
type StreamsStore interface {
StreamAppend(nodePath string, value []byte) (*Event, error)
StreamGet(nodePath string) (*Event, error)
}
type streamsStore struct {
basedir string... |
// Copyright 2019 Yunion
//
// 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 writi... |
package main
func main() {
type num int
num(5)
}
|
package handler
import (
"fmt"
"log"
"net/http"
"workshop/internal/api"
)
type Handler struct {
jokeClient api.Client
}
func NewHandler(jokeClient api.Client) *Handler {
return &Handler{
jokeClient: jokeClient,
}
}
func (h *Handler) Home(w http.ResponseWriter, r *http.Request) {
log.Printf("Fetching joke"... |
package cpu_test
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/bmizerany/assert"
"github.com/gonitor/gonitor/config"
)
//TestCpuRestGetSumPercent .
func TestCpuRestGetSumPercent(test *testing.T) {
testRouter := config.SetupTestRouter()
url := config.GetRestEndPoint("/cpu/sum/percent")
req, _... |
package ent_ex
import (
"context"
"fmt"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"time"
"net/http"
"strings"
"way-jasy-cron/common/ecron"
"way-jasy-cron/common/email"
"way-jasy-cron/cron/ecode"
"way-jasy-cron/cron/internal/dao/mail"
"way-jasy-cron/cron/internal/model/ent"
)
type JobStatus... |
package main
import (
_ "namanerp/routers"
"namanerp/models/inventory"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
_ "github.com/go-sql-driver/mysql" // import your required driver
)
func init() {
// orm.RegisterDriver("sqlite", orm.DRSqlite)
// orm.RegisterDataBase("default", "sqlite3", "datab... |
package rbootx
import "fmt"
type Memorizer interface {
Save(bucket, key string, value []byte) error
Find(bucket, key string) []byte
FindAll(bucket string) map[string][]byte
Update(bucket, key string, value []byte) error
Remove(bucket, key string) error
}
var memorizers = make(map[string]func() Memorizer)
// 注册... |
package controllers
import (
"encoding/json"
"net/http"
"strconv"
"project/config"
"project/models"
"github.com/labstack/echo"
)
/* POST /customer --> to add customer data
{
"full_name": "Irvan Tristian",
"mobile": "0811223456",
"address": "Mountain View",
"email": "irvan.t@google.com",
"i... |
/**
*
* By So http://sooo.site
* -----
* Don't panic.
* -----
*
*/
package v1
import (
"encoding/json"
"fmt"
"github.com/Git-So/blog-api/models"
"github.com/Git-So/blog-api/service"
"github.com/Git-So/blog-api/utils/api"
"github.com/Git-So/blog-api/utils/conf"
"github.com/Git-So/blog-api/utils/e"
"... |
package main
import (
metrictools "../"
"encoding/json"
"fmt"
nsq "github.com/bitly/go-nsq"
"github.com/garyburd/redigo/redis"
"log"
"time"
)
// MetricDeliver define a metric proccess task
type MetricDeliver struct {
dataService *redis.Pool
configService *redis.Pool
writer *nsq.Writer
triggerTopic... |
// Code generated; DANGER ZONE FOR EDITS
package data
import (
"bytes"
"encoding/json"
"fmt"
"gopkg.in/yaml.v2"
)
const BondDefinitionName = "bond"
type BondDefinitions map[string]BondDefinition
func (d BondDefinitions) Keys() (out []string) {
for k := range d {
out = append(out, k)
}
return out
}
func (... |
package objs
import (
"fmt"
"strconv"
"strings"
)
type Ratio struct {
Num int64
Den int64
}
var ZeroRatio = Ratio{0, 1}
func NewRatio(n int64, d int64) Ratio {
if d == 0 {
d = 1
}
return Ratio{n, d}.Reduced()
}
func Whole(n int64) Ratio {
return Ratio{n, 1}
}
func (r Ratio) String() string {
if r.Den ... |
// Copyright (c) 2018 soren yang
//
// Licensed under the MIT License
// you may not use this file except in complicance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software
// distributed und... |
package main
import (
"net/http"
"os"
"path"
"path/filepath"
"github.com/packaged/logger/v2"
"github.com/packaged/logger/v2/ld"
"go.uber.org/zap"
cli "gopkg.in/alecthomas/kingpin.v2"
)
var (
configPath = cli.Flag("config", "Path to the config yaml").Short('c').String()
devEnvironment = cli.Flag("develo... |
// Copyright (c) 2016, Samvel Khalatyan. All rights reserved.
//
// gh is the main command for GitHub cli
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"github.com/skhal/gh/env"
)
var (
commands []*Command
)
func init() {
commands = []*Command{
cmdHelp,
cmdAuth,
cmdCfg,
cmdEnv,
cmdIssues,
}
... |
package main
import "fmt"
func main() {
func(){
fmt.Println("He")
}()
this := func(){
fmt.Println("Two")
}
this()
fmt.Printf("%T, \n", this)
fmt.Println(myCallback())
thisFunc := myCallback
fmt.Printf("%T, %v\n", thisFunc(), thisFunc())
}
func myCallback() func() int {
return func() int {
return 32... |
package main
import "fmt"
func main() {
a := 42
fmt.Println(a) // OUTPUT: 42
fmt.Println(&a) // OUTPUT: Memory location, pointer returns memory location of `a`
fmt.Printf("%T\n", a) //Type that is `a` OUTPUT: int
fmt.Printf("%T\n", &a) //Type that is `&a` OUTPUT: *int
//Sharing an address:
var b *int ... |
package dockercomposeservice
import (
"context"
"github.com/tilt-dev/tilt/internal/controllers/apicmp"
"github.com/tilt-dev/tilt/internal/dockercompose"
"github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1"
"github.com/tilt-dev/tilt/pkg/logger"
)
// Sync all the project watches with the dockercompose objects
// we'... |
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the GO_LICENSE file.
//go:build s390x || ppc64le || ppc64
// +build s390x ppc64le ppc64
package hmacsha512
//go:noescape
func block(dig *digest, p []byte)
|
// Copyright 2018 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... |
package handler
const (
ErrCodeOK = 0
ErrCodeApiGatewayFormat = 1001
ErrCodeUnknownAction = 1002
ErrCodeInvalidRequest = 1003
ErrCodeImportFail = 1004
ErrCodeReadFile = 1005
ErrCodeJsonMarshal = 1006
ErrCodeReadDB = 1007
ErrCodeCloudIdMissed = 1008
ErrCodeUpl... |
package controllers
import (
"github.com/astaxie/beego"
)
//20151004加入index主页
type IndexController struct {
beego.Controller
}
// @router / [get]
func (i *IndexController) GetIndexPage() {
StaticPageRender("./view/index.html", i.Ctx.ResponseWriter)
}
|
// Copyright 2020 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package reporters
import (
"context"
"fmt"
"regexp"
"strings"
"chromiumos/tast/errors"
)
var (
rTargetHosted = regexp.MustCompile(`(?i)chrom(ium|e)os`)
rDevNameS... |
/*
* @Description:
* @Author: ccj
* @Date: 2020-12-28 21:34:19
* @LastEditTime: 2020-12-28 21:44:23
* @LastEditors:
*/
package basic
import(
"fmt"
"time"
)
func Learn4(){
ch1 := make(chan int)
ch2 := make(chan int)
go send(ch1,0)
go send(ch2,10)
time.Sleep(time.Second)
for{
select{
cas... |
// Copyright 2021 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... |
/*
Copyright The containerd 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... |
package block
import (
"github.com/transmutate-io/cryptocore/tx"
"github.com/transmutate-io/cryptocore/types"
)
type (
ForwardBlockNavigator interface {
NextBlockHash() types.Bytes
}
BackwardBlockNavigator interface {
PreviousBlockHash() types.Bytes
}
ConfirmationCounter interface {
Confirmations() int... |
package ntfy
import (
"encoding/json"
"testing"
"github.com/TwiN/gatus/v5/alerting/alert"
"github.com/TwiN/gatus/v5/core"
)
func TestAlertDefaultProvider_IsValid(t *testing.T) {
scenarios := []struct {
name string
provider AlertProvider
expected bool
}{
{
name: "valid",
provider: AlertPro... |
package _3_smoothSailing
import (
"fmt"
"math"
)
func main() {
n := 123042
fmt.Println(isLucky(n))
}
func isLucky(n int) bool {
quontityOfNumbers := int(math.Log10(float64(n))) + 1
firstHalf := 0
secandHalf := 0
for i := 0; i < quontityOfNumbers; i++ {
if i < quontityOfNumbers/2 {
firstHalf += n % 10
... |
package renderer
import (
"bytes"
"image"
"image/draw"
"strings"
"unicode"
"github.com/driusan/de/demodel"
"github.com/driusan/de/renderer"
"golang.org/x/image/font"
"golang.org/x/image/math/fixed"
)
type PHPSyntax struct {
renderer.DefaultSizeCalcer
renderer.DefaultImageMapper
}
func (rd *PHPSyntax) Inv... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.