text stringlengths 11 4.05M |
|---|
package confsvr
import (
"bufio"
"fmt"
json "github.com/json-iterator/go"
"github.com/oceanho/gw/sdk/confsvr/param"
"io"
"io/ioutil"
"net/http"
"strings"
)
type Client struct {
options *Option
}
type Option struct {
Addr string
Service string
Version string
Proto ... |
package bd
import (
"context"
"time"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
func BorroTweet(ID string, UserID string) error {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel() // me cancela el contexto de arriba pero de ultimo por... |
package main
import (
"os"
"log"
"path/filepath"
"github.com/fsnotify/fsnotify"
"sync"
"time"
"strings"
"os/exec"
)
func dataRefreshWatcher(watcher *fsnotify.Watcher, targetDir string) {
waitMutex := &sync.Mutex{}
waitMap := make(map[string]chan bool)
for {
select {
case event := <-watcher.Events:
i... |
package plugin
import (
"fmt"
"log"
"sort"
"strings"
"sync"
plugin_v1 "github.com/cyberark/secretless-broker/internal/plugin/v1"
config_v2 "github.com/cyberark/secretless-broker/pkg/secretless/config/v2"
)
// Resolver is used to instantiate providers and resolve credentials
type Resolver struct {
EventNotifi... |
// 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 crostini
import (
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"time"
"chromiumos/tast/errors"
"chromiumos/tast/local/chrome"
"chromiumos/ta... |
package controllers
import (
"encoding/json"
"github.com/RainerGevers/tasker/config"
"github.com/RainerGevers/tasker/lib/argon"
"github.com/RainerGevers/tasker/models"
"github.com/RainerGevers/tasker/serializers"
"github.com/dgrijalva/jwt-go"
uuid "github.com/satori/go.uuid"
"io/ioutil"
"log"
"net/http"
"os... |
/*
Copyright 2021 The KodeRover 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, s... |
package apps
import (
"flag"
"fmt"
"os"
"strconv"
"net"
"github.com/BurntSushi/toml"
)
type DNSServerSetting struct {
Host string
}
type RedisSettings struct {
//Enable bool
Host string
Port int
DB int
Password string
}
func (s RedisSettings) Addr() string {
return s.Host + ":" + str... |
package model
import (
"github.com/caos/zitadel/internal/model"
"time"
)
type IamMemberView struct {
UserID string
IamID string
UserName string
Email string
FirstName string
LastName string
DisplayName string
Roles []string
CreationDate time.Time
ChangeDate time.Ti... |
package tradfri
import (
"encoding/json"
"fmt"
"github.com/dustin/go-coap"
"github.com/eriklupander/tradfri-go/dtlscoap"
"github.com/eriklupander/tradfri-go/model"
"github.com/sirupsen/logrus"
"strconv"
"strings"
)
// Client provides a declarative API for sending CoAP messages to the gateway over DTLS.
type C... |
package commands
import (
"strings"
"mvdan.cc/sh/v3/interp"
)
func IsIn(args []string) error {
if len(args) != 2 {
return interp.NewExitStatus(1)
}
values := strings.Split(args[1], " ")
for _, value := range values {
if value == args[0] {
return interp.NewExitStatus(0)
}
}
return interp.NewExitStatu... |
// ===================================== //
// author: gavingqf //
// == Please don'g change me by hand == //
//====================================== //
/*you have defined the following interface:
type IConfig interface {
// load interface
Load(path string) bool
// clear interface
Clear()
}... |
package models
import (
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"
)
type User struct {
gorm.Model
Username string
Password string
}
|
package main
import (
"image"
_ "image/png"
"math"
"math/rand"
"os"
"time"
"github.com/ByteArena/box2d"
"github.com/faiface/pixel"
"github.com/faiface/pixel/imdraw"
"github.com/faiface/pixel/pixelgl"
"golang.org/x/image/colornames"
)
const (
// Prepare for simulation. Typically we use a time step of 1/60... |
package model
import "time"
//Healthcheck
type StatusRequest struct{}
type StatusResponse struct {
Status string `json:"status"`
}
type GetApprovalRequest struct {
ID string `json:"id"`
}
type GetApprovalResponse struct {
ApprovalItem ApprovalItem `json:"approval_items"`
}
type GetApprovalsRequest struct {
Li... |
/*
Copyright 2020 The Skaffold 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, sof... |
/*
Copyright 2018 The KubeSphere 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, sof... |
// 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
import (
"auth/database"
"database/sql"
"encoding/json"
"fmt"
"log"
"net/http"
)
type Handler struct {
DB *sql.DB
}
type data map[string]interface{}
func JSONWriter(w http.ResponseWriter, data interface{}, statusCode int) {
w.WriteHeader(statusCode)
err := json.NewEncoder(w).Encode(data)
if... |
package exchange
import (
"fmt"
"net/http"
"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/metrics"
"github.com/prebid/prebid-server/openrtb_ext"
)
func BuildAdapters(client *http.Client, cfg *config.Configuration, infos config.BidderInfos, m... |
// Copyright 2018 Authors of Cilium
//
// 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 ... |
package db
import (
"go.m3o.com/client"
)
func NewDbService(token string) *DbService {
return &DbService{
client: client.NewClient(&client.Options{
Token: token,
}),
}
}
type DbService struct {
client *client.Client
}
// Count records in a table
func (t *DbService) Count(request *CountRequest) (*CountRes... |
// Copyright 2019 Liquidata, 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... |
package cli
import (
"errors"
"fmt"
"io/ioutil"
"os"
"os/exec"
"strings"
"github.com/madebyais/fast/app"
"github.com/madebyais/fast/common"
"github.com/madebyais/fast/config"
)
// Interface is an interface for cli package
type Interface interface {
Init()
}
type schema struct {
args []string
cmd string... |
//
// Copyright (c) SAS Institute 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 agre... |
package main
import (
"errors"
"fmt"
"net/http"
"time"
"github.com/kubil6y/dukkan-go/internal/data"
"github.com/kubil6y/dukkan-go/internal/email"
"github.com/kubil6y/dukkan-go/internal/validator"
)
func (app *application) createAuthenticationTokenHandler(w http.ResponseWriter, r *http.Request) {
var input cr... |
package controller
import (
"context"
"fmt"
"net"
"reflect"
"strings"
"github.com/cnf/structhash"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/tools/cache"
"... |
package cli
import (
"fmt"
"strings"
"github.com/mebyus/ffd/cli/command"
"github.com/mebyus/ffd/resource"
"github.com/mebyus/ffd/resource/fiction"
)
type downloadExecutor struct{}
func NewDownloadExecutor() *downloadExecutor {
return &downloadExecutor{}
}
func NewDownloadTemplate() (template *command.Templat... |
package main
import "fmt"
func main() {
i,j := 10,20
// like c/c++ or others go doesn't has any () parentesis in its if--else condition statement
// if..else if...else format is matter
if i<j {
fmt.Printf("%v is less than %v\n",i,j)
} else if i==j {
fmt.Printf("%v is equal to %v\n",i,j)
}else {
fmt.Print... |
// Copyright 2018 Aleksandr Demakin. All rights reserved.
package printer
import (
"bytes"
"errors"
"io/ioutil"
"testing"
"github.com/avdva/unravel/card"
"github.com/avdva/unravel/hash"
"github.com/stretchr/testify/require"
)
type errorWriter struct{}
func (e *errorWriter) Write(buff []byte) (int, error) {... |
package main
import (
"bytes"
"encoding/json"
"fmt"
"html/template"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
)
func getApibFileContent(c Collection) string {
tpl := `
# Group {{ .Info.Name }}
{{ .Info.Description }}
{{ range .Items }}
{{ .Markup }}
{{ end }}
`
t := template.New("Template")
t... |
package metrics
import (
"time"
"github.com/prometheus/client_golang/prometheus"
)
func (r *Registry) init() {
r.uptimeCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: `uptime`,
Help: `count seconds running`,
},
)
r.startUptimeC... |
package main
import "fmt"
func main() {
i := 1
//Go não tem operações aritméticas de ponteiros
var p *int = nil
p = &i // pegando o endereço da variavel i
*p++
i++
fmt.Println(p, *p, i, &i)
}
|
// Copyright 2016 Albert Nigmatzianov. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package client
import (
"errors"
"fmt"
"net/url"
"github.com/bogem/vnehm/ui"
"github.com/valyala/fasthttp"
)
const apiURL = "https://api.vk.com/met... |
// Copyright 2019 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 nbanews
type Media interface {
TargetURL() string
Fetch() error
ArticleList() []*Article
}
type Article struct {
Title string
URL string
}
|
// Copyright 2019 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 memstr
import "testing"
var (
memoryTests = map[string]int64{
"1k": 1000,
"2K": 2048,
}
)
func TestParseMemory(t *testing.T) {
for k, v := range memoryTests {
n, err := Parse(k)
if err != nil {
t.Error(err)
}
if n != v {
t.Fail()
}
}
}
|
package plugconf
import (
"reflect"
"testing"
"github.com/vim-volt/volt/lockjson"
"github.com/vim-volt/volt/pathutil"
)
func TestSortByDepends(t *testing.T) {
type input struct {
reposList []lockjson.Repos
plugconfMap map[pathutil.ReposPath]*ParsedInfo
}
cases := []struct {
input input
want []lock... |
// Copyright 2019 Liquidata, 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... |
package oidcserver
import (
"context"
"net/http"
)
// Scopes represents additional data requested by the clients about the end user.
type Scopes struct {
// The client has requested a refresh token from the server.
OfflineAccess bool
// The client has requested group information about the end user.
Groups bool... |
/*
Links
* http://yjyruwufuhi.github.com/1.html
* http://yjyruwufuhi.github.com/2.html
* http://yjyruwufuhi.github.com/3.html
* http://yjyruwufuhi.github.com/4.html
* http://yjyruwufuhi.github.com/5.html
* http://yjyruwufuhi.github.com/6.html
* http://yjyruwufuhi.github.com/7.html
* http://yjyruwufuhi.github.com/8.html... |
package models
type Vehicle struct{
Model string `json:"model"`
Plate string `json:"plate"`
Capacity float32 `json:"capacity"`
Vin string `json:"vin"`
}
func (v *Vehicle) SetAttributes(model string, plate string, capacity float32, vin string){
v.Model = model
v.Plate = plate
v.Capacity = capacity
v.Vin = vin
... |
/*
* REST API
*
* Rockset's REST API allows for creating and managing all resources in Rockset. Each supported endpoint is documented below. All requests must be authorized with a Rockset API key, which can be created in the [Rockset console](https://console.rockset.com). The API key must be provided as `ApiKey <ap... |
package main
// WARNING: API of Kubeconform is still under development and not yet
// considered stable
import (
"github.com/yannh/kubeconform/pkg/validator"
"log"
"os"
)
func main() {
filepath := "../fixtures/valid.yaml"
f, err := os.Open(filepath)
if err != nil {
log.Fatalf("failed opening %s: %s", filepat... |
/*
Copyright 2020 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... |
package todotxt
import (
"errors"
"sort"
"time"
)
// TaskSortByType represents type of sorting element and order.
//go:generate stringer -type TaskSortByType -trimprefix Sort -output sort_type.go
type TaskSortByType uint8
// Flags for defining sorting element and order.
const (
SortTaskIDAsc TaskSortByType = iot... |
// Copyright 2020 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 (c) 2018-present, MultiVAC Foundation
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
package imvvm
import (
"github.com/multivactech/MultiVAC/model/shard"
"github.com/multivactech/MultiVAC/model/wire"
)
// DeployInitializer... |
package main
import "strconv"
//面试题46. 把数字翻译成字符串
//给定一个数字,我们按照如下规则把它翻译为字符串:0 翻译成 “a” ,1 翻译成 “b”,……,11 翻译成 “l”,……,25 翻译成 “z”。一个数字可能有多个翻译。请编程实现一个函数,用来计算一个数字有多少种不同的翻译方法。
//
//
//
//示例 1:
//
//输入: 12258
//输出: 5
//解释: 12258有5种不同的翻译,分别是"bccfi", "bwfi", "bczi", "mcfi"和"mzi"
//思路: 动态规划
// dp[s] = dp[s-1] + dp[s-2]
func tran... |
package module
import (
"github.com/l-dandelion/cwgo/data"
)
type Counts struct {
CalledCount int64
AcceptedCount int64
CompletedCount int64
HandlingNumber int64
}
type SummaryStruct struct {
Called int64 `json:"called"`
Accepted int64 `json:"accepted"`
Completed int64 `json:"comple... |
package adapter
import (
"fmt"
"github.com/dustin/go-humanize"
"github.com/rhymond/go-money"
"github.com/tidwall/gjson"
"github.com/zcong1993/badge-service/utils"
)
var (
opencUnknownInput = makeUnknownTopicInput("opencollective")
opencTopics = []string{"backers", "contributors", "balance", "yearly"}
)
... |
package main
import "fmt"
// the heap type
type heap []int
// insert adds element e to the heap
func (h *heap) insert(e int) {
l := len(*h)
*h = (*h)[0 : l+1]
s := *h
s[l] = e
for i := l; i > 0; i = parent(i) {
p := parent(i)
if s[p] <= s[i] {
break
}
s[i], s[p] = s[p], s[i]
}
}
// pop returns the ... |
package core
import (
domain "github.com/I-Reven/Hexagonal/src/domain/grpc"
"github.com/I-Reven/Hexagonal/src/infrastructure/grpc/core/handler"
"google.golang.org/grpc"
)
type Grpc struct{}
func (Grpc) Route() *grpc.Server {
server := grpc.NewServer()
domain.RegisterPingServer(server, &handler.Ping{})
return... |
package web
import (
"net/http"
"encoding/json"
"encoding/base64"
"io"
"io/ioutil"
"fa/s3util"
"fa/model"
"fa/openface"
"os"
"fmt"
)
type faceRecogInput struct {
Image string `json:"image"`
}
type celebOutput struct {
Name string `json:"name"`
Confidence string `js... |
package email
import (
"bytes"
"fmt"
"html/template"
"log"
"net/smtp"
)
const (
SMTP_USERNAME = "Eric.Irwin1124@gmail.com"
SMTP_PASSWORD = "UvHw2w6jhpJl"
SMTP_SERVER = "mail.smtp2go.com"
SMTP_PORT = 2525
)
//Request struct
type Request struct {
from string
to []string
subject string
body ... |
package method
import (
"net/http"
"reflect"
"shared/utility/httputil"
)
type HttpPostHandler struct {
*httputil.HttpMethodAdapter
}
func NewHttpPostHandler() *HttpPostHandler {
return &HttpPostHandler{
HttpMethodAdapter: httputil.NewHttpMethodAdapter(http.MethodPost),
}
}
func (p *HttpPostHandler) FilterMet... |
package cli
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
"strings"
)
func apiHost() string {
return fmt.Sprintf("%s:%d", provideWebHost(), provideWebPort())
}
func apiURL(path string) string {
path = strings.TrimLeft(path, "/")
return fmt.Sprintf("http://%s:%d/api/%s", provideWebHost(), provideWebPort(), pat... |
package main
import "fmt"
var arr []string
func searchWords(str string, count int) {
if len(str) == 0 {
return
}
arr = append(arr, str)
searchWords(str[1:], count + 1)
fmt.Printf("arr: %v, count: %v \n", arr, count)
}
func main() {
arr = make([]string, 0)
searchWords("fine", 0)
}
|
// 178.Checking erros err sample || panic log 錯誤回報
// https://golang.org/pkg/builtin/#panic
// log.Println()
// log.Fatalln() // 印出錯誤後 結束 exit
// os.Exit()
// log.Panicln() // 可以回復
// deferred functions run
// can use “recover”
// panic() CMD 跑才 看的到錯誤訊息
// panic() // 在 "當前goroutine" 增加deferr 最後執行 nil 0 改成 1 程式繼續
... |
package rigger
import (
"github.com/AsynkronIT/protoactor-go/actor"
"github.com/golang/protobuf/proto"
)
type riggerRestServer struct {
}
func (r *riggerRestServer) OnRestarting(ctx actor.Context) {
}
func (r *riggerRestServer) OnStarted(ctx actor.Context, args interface{}) error {
return nil
}
func (r *rigge... |
package openrtb_ext
type ExtBematterfull struct {
Env string `json:"env"`
Pid string `json:"pid"`
}
|
// Package input ...
package input
import (
"github.com/go-rod/rod/lib/proto"
"github.com/ysmood/gson"
)
// Modifier values
const (
ModifierAlt = 1
ModifierControl = 2
ModifierMeta = 4
ModifierShift = 8
)
// Key symbol
type Key rune
// keyMap for key description
var keyMap = map[Key]KeyInfo{}
// key... |
package main
// Structures used to represent the schema.
type JsonSchema struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Type string `json:"type,omitempty"`
Definitions map[string]*JsonSchema `json:"defini... |
// Command query implements a simple CLI for querying a PHP AST.
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/stephens2424/php/ast"
"github.com/stephens2424/php/parser"
"github.com/stephens2424/php/query"
)
func main() {
recursive := flag.Bool("r", false, "Recur... |
package swordoffer
import "sort"
//剑指 Offer 38. 字符串的排列
//输入一个字符串,打印出该字符串中字符的所有排列。
//
//
//
//你可以以任意顺序返回这个字符串数组,但里面不能有重复元素。
//
//
//
//示例:
//
//输入:s = "abc"
//输出:["abc","acb","bac","bca","cab","cba"]
//
//
//限制:
//
//1 <= s 的长度 <= 8
func permutation(s string) []string {
array := []byte(s)
n := len(s)
dic := make([... |
package tariff
import (
"errors"
"net/http"
"sync"
"time"
"github.com/cenkalti/backoff/v4"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/tariff/ngeso"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/request"
"slices"
)
type Ngeso struct {
mux sync.Mutex
log *ut... |
package minstack
import "github.com/alandtsang/leetcode-go/stack"
type Stack = stack.Stack
type MinStack struct {
min *Stack
data *Stack
}
/** initialize your data structure here. */
func Constructor() MinStack {
minStack := stack.NewStack()
dataStack := stack.NewStack()
return MinStack{
min: minStack,
d... |
package mservice
type ServiceHousekeep struct {
ServiceRecord
Price string
TimeAvailable string
OptType int //1: 自带 : 2:雇主提供
Hint string
Description string
}
|
package controller
import (
"github.com/gin-gonic/gin"
"dawn_media/conf"
"dawn_media/model"
"dawn_media/tool"
"net/http"
"strconv"
"time"
"errors"
"strings"
)
/**
用户前台管理评论
*/
func PageODUserComment(c *gin.Context) {
var authUser *model.User
if t, ok := c.Get("authUser"); ok {
authUser = t.(*model.User)
... |
package utility
import (
"context"
"database/sql"
"fmt"
"net/url"
"time"
kitlog "github.com/go-kit/kit/log"
)
// BuildDsn uses the provided values to build a URL based DSN to connect to a database.
//
// Parameters
// scheme is the connection scheme, such as "sqlserver"
// username: to authenticate to the ... |
package model
//微信支付回调返回示例
//<xml>
//<appid><![CDATA[wx2421b1c4370ec43b]]></appid>
//<attach><![CDATA[支付测试]]></attach>
//<bank_type><![CDATA[CFT]]></bank_type>
//<fee_type><![CDATA[CNY]]></fee_type>
//<is_subscribe><![CDATA[Y]]></is_subscribe>
//<mch_id><![CDATA[10000100]]></mch_id>
//<nonce_str><![CDATA[5d2b6c2a8db5... |
// Copyright 2015 The go-aita Authors
// This file is part of the go-aita library.
//
// The go-aita library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at ... |
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
//
package aws
import (
"context"
"github.com/aws/aws-sdk-go-v2/service/secretsmanager"
)
// SecretsManagerAPI represents the series of calls we require from the AWS SDK v2 SecretsManager Client
type Se... |
package main
import (
"log"
"os"
"github.com/w-zengtao/socket-server/api"
"github.com/w-zengtao/socket-server/models"
"github.com/w-zengtao/socket-server/sockets"
"github.com/w-zengtao/socket-server/sources"
)
func init() {
log.SetOutput(os.Stdout)
}
var (
forever = make(chan bool)
)
func main() {
manager... |
package dbs
import (
json "cjson/qson"
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
)
type DB struct {
WriteDB *sql.DB
ReadDB *sql.DB
}
func getDB(dbName string, url string) *sql.DB {
db, err := sql.Open(dbName, url)
if err != nil {
fmt.Println("数据库连接异常...", err)
}
db.SetMaxIdleConns(1)
db.S... |
package dynamicstruct
import (
"errors"
"reflect"
"github.com/goldeneggg/structil/util"
)
const (
capBuilderField = 10
defaultStructName = "DynamicStruct"
// SampleString is sample string value
SampleString = ""
// SampleInt is sample int value
SampleInt = int(1)
// SampleByte is sample byte value
Samp... |
package users
import (
"errors"
"fmt"
"net/mail"
"strings"
"github.com/globalsign/mgo/bson"
"golang.org/x/crypto/bcrypt"
)
var bcryptCost = 13
//User represents a user account in the database
type User struct {
ID bson.ObjectId `json:"id" bson:"_id"`
Email string `json:"email"`
PassHash ... |
package cmd
import (
"fmt"
"github.com/ddspog/doni/project"
"github.com/spf13/cobra"
)
// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version of Hugo",
Long: `All softwares has versions. This is doni's`,
Run: func(cmd *cobra.Command, args []s... |
package main
func minCut(s string) int {
n := len(s)
dp := make([]int, n+1)
dp[0] = -1
for i := 1; i <= n; i++ {
dp[i] = i
for j := 0; j < i; j++ {
if isPal(s, j, i-1) {
dp[i] = Min(dp[j]+1, dp[i])
}
}
}
return dp[n]
}
func isPal(s string, l, r int) bool {
for l < r {
if s[l] != s[r] {
ret... |
package activity
import (
"github.com/gin-gonic/gin"
"net/http"
"xj_web_server/httpserver/servermiddleware"
"xj_web_server/model"
"xj_web_server/module"
"xj_web_server/util"
)
type ActivityReq struct {
servermiddleware.BaseReq
Number int `form:"number" json:"number"` //分页数
Page int `from:"page" json:"page"... |
package function
import (
"testing"
)
func Test_isPossible(t *testing.T) {
type args struct {
x int
}
tests := []struct {
name string
args args
want int
}{
{"test1", args{111111}, 1},
{"test2", args{122345}, 1},
{"test3", args{223450}, 0},
{"test4", args{123789}, 0},
}
for _, tt := range tests ... |
package routers
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/context/param"
)
func init() {
beego.GlobalControllerRouter["Android-api/controllers:Barcode2Controller"] = append(beego.GlobalControllerRouter["Android-api/controllers:Barcode2Controller"],
beego.ControllerComments{
... |
package main
import "unicode"
//864. 获取所有钥匙的最短路径
//给定一个二维网格 grid ,其中:
//
//'.' 代表一个空房间
//'#' 代表一堵
//'@' 是起点
//小写字母代表钥匙
//大写字母代表锁
//我们从起点开始出发,一次移动是指向四个基本方向之一行走一个单位空间。我们不能在网格外面行走,也无法穿过一堵墙。如果途经一个钥匙,我们就把它捡起来。除非我们手里有对应的钥匙,否则无法通过锁。
//
//假设 k 为 钥匙/锁 的个数,且满足 1 <= k <= 6,字母表中的前 k 个字母在网格中都有自己对应的一个小写和一个大写字母。换言之,每个锁有唯一对应的钥匙,每个钥匙... |
// Package records contains functions to generate resource records from
// mesos master states to serve through a dns server
package records
import (
"crypto/sha1"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net"
"net/http"
"net/url"
"strconv"
"strings"
"time"
"github.com/mesosphere/mesos-dns/errorutil"
... |
package main
//216. 组合总和 III
//找出所有相加之和为n 的k个数的组合。组合中只允许含有 1 -9 的正整数,并且每种组合中不存在重复的数字。
//
//说明:
//
//所有数字都是正整数。
//解集不能包含重复的组合。
//示例 1:
//
//输入: k = 3, n = 7
//输出: [[1,2,4]]
//示例 2:
//
//输入: k = 3, n = 9
//输出: [[1,2,6], [1,3,5], [2,3,4]]
func combinationSum3(k int, n int) [][]int {
var dfs func(s, target, dep int) [][... |
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
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 ag... |
package controller
import (
"fmt"
"io"
"net"
"code.aliyun.com/runningguys/agent/registry"
"github.com/coreos/etcd/clientv3"
)
type providerAgent struct {
port string
destPort string
}
func startProviderAgent(property registry.Property, cli *clientv3.Client) {
reg := new(registry.EtcdRegistry)
reg.Init(... |
// 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 bluetooth
// DeviceCapability is a name of a device capability, matching keys of the
// capabilities map returned from calling PeripheralKit.GetCapabilities().
type ... |
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License for license information.
package main
import (
"io"
"github.com/mattermost/mattermost-server/model"
)
func AsSlackAttachment(in io.Reader) (func(post *model.Post), error) {
parsed, err := parse(in, nil)
if err != nil {
return n... |
package controllers
import (
"fmt"
"github.com/gin-gonic/gin"
)
type User struct{}
//login
func (u *User) Login(c *gin.Context) {
fmt.Println("ni hao")
return
}
|
package core
import (
"fmt"
"log"
"net/http"
)
type Config struct {
Port int
Mysql *MysqlConfig
}
type Instance struct {
config *Config
channels *Channels
}
func (config *Config) NewInstance() *Instance {
this := &Instance{
config: config,
channels: config.NewChannels(),
}
return this
}
var obje... |
package main
import (
"github.com/CRUD-Gin-Gorm/Route"
"github.com/CRUD-Gin-Gorm/Config"
"github.com/jinzhu/gorm"
_ "github.com/lib/pq"
)
var err error
func main() {
Config.Db, err = gorm.Open("postgres", "user=sirawich dbname=booker sslmode=disable")
if err != nil {
panic(err)
}
defer Config.Db.Close()
... |
package LeetCode
import "fmt"
func Code35() {
nums := []int{1, 3, 5, 6}
target := 0
fmt.Println(searchInsert(nums, target))
}
/**
给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。
你可以假设数组中无重复元素。
示例 1:
输入: [1,3,5,6], 5
输出: 2
示例 2:
输入: [1,3,5,6], 2
输出: 1
示例 3:
输入: [1,3,5,6], 7
输出: 4
示例 4:
输入: [1,3,... |
package pdf
import (
"fmt"
"io"
)
type Object interface {
String() string
}
type NullObject struct {}
func NewNullObject() *NullObject {
return &NullObject{}
}
func (obj *NullObject) String() string {
return "null"
}
type IndirectObject struct {
Number int64
Generation int64
Value Object
Stream []byte
}
... |
package wasmvm
import (
"fmt"
"github.com/zhaohaijun/matrixchain/common/log"
"github.com/zhaohaijun/matrixchain/errors"
"github.com/zhaohaijun/matrixchain/vm/wasmvm/exec"
"github.com/zhaohaijun/matrixchain/vm/wasmvm/util"
)
type LogLevel byte
const (
Debug LogLevel = iota
Info
Error
)
type ParamType byte
... |
// Copyright 2022 YuWenYu All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package adapter
import (
"fmt"
"github.com/go-xorm/xorm"
"github.com/spf13/cast"
"github.com/yuw-pot/pot/data"
E "github.com/yuw-pot/pot/modules/err"
//E "gith... |
//112 interfaces & polymorphism
// 一個值可以有很多種type
// func (容器 類型) 接收器
// type 名稱 interface {內容...}
package main
import "fmt"
type person struct {
fname string
lname string
}
type scagent struct {
person
ltk bool
}
type human interface { //如果你可以執行 speak() 你就有我 human 的 type // 增加type
speak() // 在speak()的func 接收器裡 ... |
package main
import (
"html/template"
)
var tmplHtml = `
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bybit Funding</title>
<link rel="stylesheet" href="/static/css/bootstrap.css" />
<link rel="stylesheet" href="/static/css/style.css" />
</head>
... |
package main
import (
"fmt"
"github.com/dropbox/godropbox/database/sqlbuilder"
)
func main() {
t1 := sqlbuilder.NewTable(
"tickets",
sqlbuilder.IntColumn("id", false),
sqlbuilder.IntColumn("number", false),
)
// t1_id := t1.C("id")
t1_number := t1.C("number")
query := t1.Select(t1_number).Where(sqlbuil... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.