text stringlengths 11 4.05M |
|---|
package encoding
import (
"encoding/json"
"io"
)
// JSONDecoder implements the Decoder interface
func JSONDecoder(r io.Reader, v *map[string]interface{}) error {
d := json.NewDecoder(r)
d.UseNumber()
return d.Decode(v)
}
|
package routers
//"namanerp/controllers"
import (
"namanerp/controllers/dashboard"
"namanerp/controllers/inventory"
"github.com/astaxie/beego"
)
func init() {
// Home page
// Redirect home page to "/dashboard/finance"
beego.Router("/", &dashboard.IndexController{})
// Dashboard
beego.Router("/dashboard/fi... |
/*
Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list.
Analyze and describe its complexity.
*/
package main
func mergeKLists(lists []*ListNode) *ListNode {
if len(lists) == 0 {
return nil
}
target := lists[0]
index := make(map[int]*ListNode)
for i := 1;i < len(lists);i++ {
targ... |
// 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 udwRpc2Builder
import (
"github.com/tachyon-protocol/udw/udwBytes"
"github.com/tachyon-protocol/udw/udwFile"
"github.com/tachyon-protocol/udw/udwGoSource/udwGoParser"
"go/format"
"strconv"
)
type GenerateReq struct {
RpcDefine RpcService
FromPkgPath string
FromObjName string
TargetPk... |
package server
import (
"fmt"
"mall/app/api/web/pay/conf"
"mall/app/api/web/pay/service"
"mall/lib/net/http/middleware/cors"
"github.com/gin-gonic/gin"
)
var svr *service.Service
func Init(c *conf.Config) {
svr = service.New(c)
r := gin.Default()
router(r, c)
r.Run(fmt.Sprintf(":%s", c.Http.Port))
}
fu... |
package version_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/rdeusser/httpstat-monitor/version"
)
func TestGetHumanVersion(t *testing.T) {
version.Version = "0.1.0"
t.Run("should contain the version prelease when set explicitly", func(t *testing.T) {
version.GitDescribe = "v0.1.0... |
package gui
import "github.com/jesseduffield/gocui"
type listView struct {
viewName string
context string
getItemsLength func() int
getSelectedLineIdxPtr func() *int
handleFocus func(g *gocui.Gui, v *gocui.View) error
handleItemSelect func(g *gocui.Gu... |
package main
import (
"fmt"
)
func main() {
// slice
// composite literal; slice literal
x := []int{7, 9, 42}
for i, _ := range x {
fmt.Println(i, "-", x[i])
}
y := make([]int, 0, 10)
y = append(y, 777)
for i, v := range y {
fmt.Println(i, "-", v)
}
// map
// composite literal; map literal
m := ma... |
package app
import (
"context"
"os"
"go.uber.org/dig"
"knife-panel/internal/app/bll/impl"
"knife-panel/internal/app/config"
"knife-panel/pkg/auth"
"knife-panel/pkg/logger"
)
type options struct {
ConfigFile string
ModelFile string
WWWDir string
SwaggerDir string
MenuFile string
Version string
... |
package listener
// From antlr parse tree create Fault AST
import (
"fault/ast"
"fault/parser"
"fmt"
"log"
"strconv"
"strings"
"github.com/antlr/antlr4/runtime/Go/antlr"
)
type FaultListener struct {
*parser.BaseFaultParserListener
stack []interface{}
AST *ast.Spec
}
func (l *FaultListener) push(n inte... |
package parse
import (
"subc/ast"
"subc/scan"
)
// constExpr returns a binary expression that must be a constant.
func (p *parser) constExpr() ast.Expr {
return p.binaryExpr()
}
/*
* expr :=
* asgmnt
* | asgmnt , expr
*/
func (p *parser) expr() ast.Expr {
n := p.asgmnt()
for {
tok := p.peek()
if tok.... |
package min
import (
"LeetCodeGo/base"
"LeetCodeGo/utils"
"container/list"
"log"
)
/**
给定一个二叉树,找出其最小深度。
最小深度是从根节点到最近叶子节点的最短路径上的节点数量。
说明: 叶子节点是指没有子节点的节点。
示例:
给定二叉树 [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15 7
返回它的最小深度 2.
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/min... |
package main
import (
"GoNet/goWeb"
"fmt"
"io"
"net/http"
)
// 使用处理器
type HttpHandler struct {}
func (h *HttpHandler)ServeHTTP(w http.ResponseWriter, req *http.Request) {
fmt.Println("Inside httpHandler")
//_, _ = fmt.Fprintf(w, "HttpHandler : Hello,"+req.URL.Path[1:]) // 写法1
_, _ = io.WriteString(w, "HttpHa... |
package main
import (
"os"
"testing"
)
const test_src = `
productA:
name: Product A
cost: 1400
sagio-price: 1500
nayax-price: 1500
mobilepay-price: 1600
machine: manatee
tags:
- soft-drink
productB:
name: Product B
cost: 1403
sagio-price: 1503
nayax-price: 1503
mobilepay-price: 1603
m... |
package servicemanager
import (
"encoding/binary"
"github.com/couchbase/cbauth/service"
)
func decodeRev(b service.Revision) uint64 {
return binary.BigEndian.Uint64(b)
}
func encodeRev(rev uint64) service.Revision {
ext := make(service.Revision, 8)
binary.BigEndian.PutUint64(ext, rev)
return ext
}
|
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package loginminutemaid
import (
"context"
"time"
"chromiumos/tast/local/chrome"
"chromiumos/tast/testing"
)
func init() {
testing.AddTest(&testing.Test{
Func: Chro... |
package controllers
import "github.com/astaxie/beego"
type IndexController struct {
beego.Controller
}
func (this *IndexController) Get() {
this.Layout = "layout/home.tpl"
this.TplNames = "home.tpl"
this.LayoutSections = make(map[string]string)
this.LayoutSections["header"] = "common/header.tpl"
this.Layo... |
package tmdb
import (
"fmt"
"net/http"
"net/url"
"strconv"
)
const searchEndpoint = "/search/%s?api_key=%s&language=en-US"
// SearchResponse from TMDB.
type SearchResponse struct {
Page int `json:"page"`
Results []SearchResult `json:"results"`
TotalResults int `json:"total_r... |
// 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... |
/* uinit.go: a simple init launcher
* Work based on https://github.com/hpc/kraken/blob/master/utils/layer0/uinit/uinit.go
*
* Author: J. Lowell Wofford <lowell@lanl.gov>
* Author: Benjamin S. Allen <bsallen@alcf.anl.gov>
*
* This software is open source software available under the BSD-3 license.
* Copyright (c)... |
package network
import (
"fmt"
"github.com/opsbot/zerotier/api"
"github.com/spf13/cobra"
)
// ListCommand returns a cobra command
func ListCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "list networks",
Run: func(cmd *cobra.Command, args []string) {
data := api.NetworkList()
... |
// Copyright 2019 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package platform
import (
"context"
"strings"
"github.com/shirou/gopsutil/v3/process"
"chromiumos/tast/common/testexec"
"chromiumos/tast/errors"
"chromiumos/tast/loc... |
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you ... |
package sql
import (
_ "github.com/lib/pq"
"github.com/caos/zitadel/internal/config/types"
"github.com/caos/zitadel/internal/errors"
)
type Config struct {
SQL types.SQL
}
func Start(conf Config) (*SQL, error) {
client, err := conf.SQL.Start()
if err != nil {
return nil, errors.ThrowPreconditionFailed(err, ... |
package connector
//任务配置表
type TaskCfg struct {
Value int32
Rewards string
}
//经验配置表
type UplevelCfg struct {
Exp int32
Rewards int32
ExtraRewards int32
}
type ItemCfg struct {
SellPrice int32
BuyPrice string
BuyAddID string
VipCard int32
}
//cns配置
type CnsConfig struct {
CnsHost ... |
package queue
import (
"context"
"fmt"
"sync"
"time"
log "github.com/golang/glog"
"github.com/mongodb/mongo-go-driver/bson"
"github.com/mongodb/mongo-go-driver/bson/primitive"
"github.com/mongodb/mongo-go-driver/mongo"
"github.com/mongodb/mongo-go-driver/mongo/options"
)
// Queue is queue processing struct.... |
package token
type Type string
const (
UNDEFINED = "undefined"
EOF = "EOF"
// Symbols.
PLUS = "+"
MINUS = "-"
ASTERISK = "*"
SLASH = "/"
OR = "||"
AND = "&&"
GT = ">"
GTE = ">="
LT = "<"
LTE = "<="
EQUAL = "=="
BANG = "!"
RPAREN = "RPAREN"
LPA... |
package main
import "github.com/monsieurtib/memcached-driver/pkg"
func main() {
var client = pkg.NewClient()
client.Set("hello", []byte("world"))
result, _ := client.Get("hello")
println("********************************", string(result))
}
|
package manager
import "github.com/rancher/catalog-service/model"
func (m *Manager) removeCatalogsNotInConfig() error {
var catalogs []model.CatalogModel
m.db.Where(&model.CatalogModel{
Catalog: model.Catalog{
EnvironmentId: "global",
},
}).Find(&catalogs)
for _, catalog := range catalogs {
if _, ok := m... |
package goimpl
import (
"bytes"
"errors"
"fmt"
"io"
"net/rpc"
"reflect"
"strings"
"testing"
"github.com/sergi/go-diff/diffmatchpatch"
)
func TestMethods(t *testing.T) {
tc := []struct {
opts GenOpts
expected string
shouldError bool
}{
{
opts: GenOpts{
PkgName: "pkg",
... |
// SPDX-License-Identifier: ISC
// Copyright (c) 2014-2020 Bitmark Inc.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package litecoin
import (
"crypto/sha256"
"github.com/bitmark-inc/bitmarkd/currency/bitcoin"
"github.com/bitmark-inc/bitmarkd/fault"
"github.c... |
package main
import (
"fmt"
"time"
"bitbucket.org/garyyu/algo-trading/go-binance"
"sync"
)
/*
* KLines Data Updating. 5Min Lines
*/
func HourlyOhlcRoutine(wg *sync.WaitGroup) {
defer wg.Done()
interval := binance.Hour
totalQueryRet := 0
totalQueryNewRet := 0
fmt.Printf("%s KlineTick Start: \t%s\n\n", st... |
package heyfyiserver
import (
"strings"
"github.com/gocraft/web"
)
type URL string
const (
HomeUrl URL = "/"
ListFactUrl URL = "/fact"
CreateFactUrl URL = "/fact/create"
ViewFactUrl URL = "/fact/view/:factId"
DeleteFactUrl URL = "/fact/delete/:factI... |
package api
import (
"encoding/json"
"go.mongodb.org/mongo-driver/bson"
"jxc/auth"
"time"
"github.com/gin-gonic/gin"
"io/ioutil"
"jxc/models"
"jxc/serializer"
"net/http"
)
// AddCustomerPrice 操作的是customer_product_price这张表
// 主要有两个地方使用:1.售价管理页面 2.客户下订单时没有对应的售价
func AddCustomerPrice(c *gin.Context) {
token ... |
package main
/*
* Daily Coding Problem: Problem #83
* Daily Coding Problem: Problem #596 [Medium]
*
Invert a binary tree.
For example, given the following tree:
a
/ \
b c
/ \ /
d e f
should become:
a
/ \
c b
\ / \
f e d
*/
import (
"fmt"
"os"
"binary_tree/tree"
)
func main() {
r... |
/*
* KIAB SDK
*
* KIAB SMS Service
*
* OpenAPI spec version:
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
package swagger
type SmsRequest struct {
To float32 `json:"to"`
Message string `json:"message"`
Service string `json:"service"`
Validity float32 `json:"validity,omite... |
package reporter
import (
"golang.org/x/net/context"
"google.golang.org/grpc/grpclog"
"bufio"
pb "github.com/lintflow/core/proto"
"github.com/pborman/uuid"
"io"
"os"
)
type reporter struct {
s *pb.Service
lookup pb.LookupdServiceClient
}
func New(s *pb.Service, lookuper pb.LookupdServiceClient) pb.Rep... |
package img
import (
"os"
"log"
"image/jpeg"
"fmt"
"image"
)
func ParseImg(m image.Image) [][]string {
bounds := m.Bounds()
// fmt.Println(bounds.Dx(), " x ", bounds.Dy())
rowHex := make([]string, 0, bounds.Dx())
imgHex := make([][]string, 0, bounds.Dy())
for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
row... |
package main
func myPow(x float64, n int) float64 {
sign := true
if n < 0 {
n = -n
sign = false
}
ans := 1.
for n != 0 {
if (n & 1) != 0 {
ans *= x
}
x *= x
n >>= 1
}
if sign {
return ans
}
return 1. / ans
}
func m... |
package main
import (
"fmt"
)
/*
给定一个数组和目标值,找出数组中和为目标值的两个数
nums = [2, 7, 11, 15] , target = 9
返回格式下标值[0, 1]
*/
func TweSum(nums []int, target int) []int {
hash := make(map[int]int)
//遍历将数组的下标和值放入map处理
for i, value := range nums {
//查询另一个值是否在map中
if j, ok := hash[target-value]; ok {
return []int{i, j}
... |
package app
import (
"github.com/ionous/sashimi/meta"
"github.com/ionous/sashimi/util/ident"
)
type View interface {
View() ident.Id
Viewer() ident.Id
InView(meta.Instance) bool
ChangedView(meta.Instance, ident.Id, meta.Instance) bool
EnteredView(meta.Instance, ident.Id, meta.Instance) bool
}
|
// Alignment is about placing fields on address alignment boundaries
// for more efficient reads and writes to memory.
// Sample program to show how struct types align on boundaries.
package main
import (
"fmt"
"unsafe"
)
// No byte padding.
type nbp struct {
a bool // 1 byte sizeof 1
b bool // 1 byte si... |
package mr
import "fmt"
import "log"
import "net/rpc"
import "hash/fnv"
import "os"
import "io/ioutil"
import "time"
import "sort"
import "math/rand"
import "encoding/json"
//import "../util"
//
// Map functions return a slice of KeyValue.
//
type KeyValue struct {
Key string
Value string
}
//
type KeyValues str... |
package main
import (
"fmt"
"github.com/hpcloud/tail"
log "github.com/sirupsen/logrus"
)
func initLog() {
// app started
log.WithFields(log.Fields{"Started": 1}).Info("Order:Log")
go watchNwnxeeLog()
}
func watchNwnxeeLog() {
t, err := tail.TailFile("/logs/nwnx.txt", tail.Config{Follow: true})
for line := ... |
package db_test
import (
"context"
"strings"
"testing"
"github.com/carlmjohnson/be"
"github.com/spotlightpa/almanack/internal/db"
)
func TestRoles(t *testing.T) {
p := createTestDB(t)
q := db.New(p)
ctx := context.Background()
r, err := q.UpsertRolesForAddress(ctx, db.UpsertRolesForAddressParams{
EmailAd... |
package main
import (
"fmt"
"log"
"net/http"
"github.com/Lunchr/luncher-api/db"
luncherFacebook "github.com/Lunchr/luncher-api/facebook"
"github.com/Lunchr/luncher-api/handler"
"github.com/Lunchr/luncher-api/router"
"github.com/Lunchr/luncher-api/session"
"github.com/Lunchr/luncher-api/storage"
"github.com/... |
package documents
import (
"fmt"
"github.com/hachi-n/full-text-search-engine/internal/architecture"
"github.com/hachi-n/full-text-search-engine/internal/util"
"io/ioutil"
"os"
"path/filepath"
)
type ID = int
type TextFilePath = string
type NgramDocumentMap map[ID]TextFilePath
const (
documentMapFileName = "d... |
package dashrates
import (
"encoding/json"
"io/ioutil"
"net/http"
"time"
)
// DigifinexAPI implements the RateAPI interface and contains info necessary for
// calling to the public Digifinex price ticker API.
type DigifinexAPI struct {
BaseAPIURL string
PriceTickerEndpoint string
}
// NewDigifinexAPI ... |
package util_test
//
// Copyright (c) 2019 ARM Limited.
//
// SPDX-License-Identifier: MIT
//
// 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 ... |
package etcd
import (
"context"
"fmt"
"go.etcd.io/etcd/clientv3"
"time"
)
var (
etcdComponent *EtcdComponent = &EtcdComponent{}
)
func NewEtcdComponent () *EtcdComponent {
return etcdComponent
}
type EtcdComponent struct {
Name string
Client *clientv3.Client
}
type EtcdStarter struct {
options *Optio... |
package model
import (
"bilibili/drivers/mysql"
"gorm.io/gorm"
)
type BilibiliDoMsg struct {
Id int `gorm:"primaryKey"`
Name string
Sid string
Msg string
}
func (bda *BilibiliDoMsg) BilibiliDoMsgAdd(params BilibiliDoMsg)error {
var result *gorm.DB
result = mysql.Db.Create(¶ms)
return result.Error
}
|
/* test the utreexo forest */
package main
import (
"bufio"
"flag"
"fmt"
"os"
"runtime"
"runtime/pprof"
"time"
"github.com/mit-dci/utreexo/utreexo"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/opt"
)
var maxmalloc uint64
var genproofs = flag.Bool("genproofs", false, "Generate... |
package main
import (
"sort"
"fmt"
)
func main() {
pair := [][]int{{1,2},{2,3},{1,1},{4,5},{3,3}}
sort.Slice(pair, func(i, j int) bool {
return pair[i][0]<pair[j][0]
})
fmt.Println(pair)
sort.Slice(pair, func(i, j int) bool {
return pair[i][1]<pair[j][1]
})
fmt.Pri... |
// Copyright (C) 2019-2020 Zilliz. 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 l... |
package main
import (
"fmt"
"time"
)
func reader(arr []int, out chan int) {
for _, i := range arr {
out <- i
}
}
func writer(in chan int) {
for i := range in {
fmt.Println(i)
}
}
func main() {
var arr = make([]int, 100)
var c = make(chan int)
go reader(arr, c)
go writer(c)
time.Sleep(time.Second * ... |
// Copyright 2018 Erik Adelbert. All right reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ignore
package main
import (
"fmt"
"sync"
"time"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on tha... |
package main
import "fmt"
func recuperarExecucao() {
if r := recover(); r != nil {
fmt.Println("Execução recuperada!")
}
}
func alunoAprovado(n1, n2 float64) bool {
defer recuperarExecucao()
media := (n1 + n2) / 2
if media > 6 {
return true
} else if media < 6 {
return false
}
panic("A MÉDIA É EXATAME... |
package controllers
import (
"net/http"
"strconv"
"github.com/google/uuid"
"github.com/labstack/echo"
"github.com/lndaquino/segmed-backend/pkg/entity"
"github.com/lndaquino/segmed-backend/pkg/errors"
)
// FileController struct models a controller for file routes
type FileController struct {
usecase FileUsecas... |
package main
import (
"fmt"
)
func main() {
object := map[string]string{"name": "SynCROSS", "age": "18"} // * map[type of key]type of value
for _, value := range object {
fmt.Println(value)
}
}
|
package websocket
import "time"
const (
defaultWriteCap = 1024
invalidPackageLength = -1
)
var (
activeTimeoutTime time.Duration
readTimeout time.Duration
writeTimeout time.Duration
)
func init() {
activeTimeoutTime = 15 * time.Millisecond * 1000
readTimeout = time.Millisecond * 1000
writeTi... |
package Models
import "github.com/jinzhu/gorm"
type Machine struct {
gorm.Model
Machine string `json:"machine"`
MsgTaskId int `json:"msg_task_id"`
}
//默认表明为accounts 这里更改为account
func (Machine) TableName() string {
return "machine"
}
|
package dex
import (
"context"
"sync"
"time"
oidc "github.com/coreos/go-oidc"
dexstorage "github.com/dexidp/dex/storage"
"github.com/ghodss/yaml"
"github.com/pkg/errors"
"github.com/replicatedhq/kots/kotsadm/pkg/k8s"
"github.com/replicatedhq/kots/pkg/identity"
dextypes "github.com/replicatedhq/kots/pkg/iden... |
package main
import "fmt"
func main() {
sl := []int{1}
k := 1
reverse(sl)
dummy := New(sl)
list := rotateRight(dummy.Next, k)
newSlice := convert(list)
fmt.Println(newSlice)
}
func reverse(sl []int) {
i, j := 0, len(sl) - 1
for i < j {
sl[i], sl[j] = sl[j], sl[i]
i++
j--
}
}
func convert(head *ListN... |
//+build !prod
package strategy
import (
"github.com/joshprzybyszewski/cribbage/model"
)
func strToCards(s []string) []model.Card {
c := make([]model.Card, len(s))
for i, str := range s {
c[i] = model.NewCardFromString(str)
}
return c
}
func strToPeggedCards(s []string) []model.PeggedCard {
c := make([]mode... |
// Copyright 2018 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package camera
import (
"context"
"fmt"
"path/filepath"
"chromiumos/tast/common/media/caps"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/gtest"
"chromiumos/... |
package analyzers
import (
"bufio"
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"
"sync"
"time"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
//ProcessInfo descibes all info to expose about a process
type ProcessInfo struct {
pidLabel, cmdlineLabel, cmdLabel, sta... |
package twse
import (
"context"
"net/http"
"net/url"
"strconv"
"strings"
"github.com/pkg/errors"
)
// ServerResponse is embedded in each Do response and
// provides the HTTP status code and header sent by the server.
type ServerResponse struct {
// HTTPStatusCode is the server's response status code. When usi... |
package main
/*
#cgo LDFLAGS: -L. -lhello
void say_hello();
*/
import "C"
func main() {
C.say_hello()
}
|
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package dbusutil
import (
"context"
"github.com/godbus/dbus/v5"
"chromiumos/tast/errors"
)
// Properties wraps D-Bus object properties.
type Properties struct {
props... |
package main
func bubbleSort(numbers []int) []int {
for i := 0; i < len(numbers); i++ {
for j := i + 1; j < len(numbers); j++ {
if numbers[j] < numbers[i] {
swap(numbers, i, j)
}
}
}
return numbers
}
func selectionSort(numbers []int) []int {
for wall := len(numbers) - 1; wall > 0; wall... |
// 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 (
"dena-hackathon21/auth"
"dena-hackathon21/entity"
"dena-hackathon21/repository"
"dena-hackathon21/twitter_handler"
"net/http"
"os"
"strconv"
"time"
"github.com/labstack/echo/v4"
)
type UserHandler struct {
userRepository *repository.UserRepository
twitterHandler *twitter_handler.T... |
package interfaces
// Ipam interface is a collection of interfaces defined to support each
// area of business logic. As new interfaces are defined they should be
// added to the Ipam interface to extend it's capabilities.
type Ipam interface {
Pools
Subnets
Reservations
Leases
}
|
package memory
import (
"errors"
"time"
"github.com/CafeLucuma/go-play/plates/pkg/adding"
"github.com/CafeLucuma/go-play/plates/pkg/listing"
)
var (
plates []Plate
)
type Storage struct {
}
// NewStorage returns a new JSON storage
func NewStorage() (*Storage, error) {
return new(Storage), nil
}
func (s *St... |
package main
import (
"fmt"
"math"
"time"
)
func main() {
// A basic set of examples showing that %v is the default format, in this
// case decimal for integers, which can be explicitly requested with %d;
// the output is just what Println generates.
integer := 23
// Each of these prints "23" (without the quo... |
// Copyright 2017 The Aiicy Team.
//
// 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 main
func main() {
// select 机制
// select机制用来处理异步IO问题;
// select机制最大的一条限制就是每个case语句里必须是一个IO操作;
// golang在语言级别支持select关键字;
}
|
package main
func main(a, b int32) {
var int32 b
b = 4 +6/7
f(2, 4)
return
}
func f(a, b int32) int32 {
return a +b
}
|
package main
import "fmt"
var x int //These can be declared in main function using :=
var y float64
var z uint8 //u stands for unsigned uint8 goes from 0 - 255 (only these values can be assigned to this variable of this type.
//byte is an alias for uint8
var a int8 //int8 is for signed goes from -128 through 12... |
// Copyright 2018 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... |
package main
import (
"fmt"
)
/**
结构体是值传递,但是其中的成员如果是slice等引用传递类型,那么该成员依然只能是引用传递*/
type (
People struct {
Name string
Tags []string
}
)
func main() {
a := People{Name: "Lucy", Tags: []string{"1", "2", "3"}}
b := a
b.Tags[0] = "tag1"
fmt.Println(a)
fmt.Println(b)
}
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
//
package main
import (
"github.com/mattermost/mattermost-cloud/model"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func newCmdInstallationDBMigrationOperation() *cobra.Command {
cmd := &cobra.C... |
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
var _ sdk.Msg = &MsgCreatePost{}
|
package odoo
import (
"fmt"
)
// HrEmployee represents hr.employee model.
type HrEmployee struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
Active *Bool `xmlrpc:"active,omptempty"`
AddressHomeId *Many2One `xmlrpc:"address_home_id,omptempty"`
Addres... |
package aural
import (
"io/ioutil"
"log"
"os"
"path"
"github.com/mkb218/gosndfile/sndfile"
"gopkg.in/h2non/filetype.v0"
mpg "github.com/bobertlo/go-mpg123/mpg123"
)
type AudioSourceFactory func() AudioSource
type AudioSource interface {
ReadFrames(out []int32) (int64, error)
Channels() int32
SampleRate(... |
package main
import "fmt"
func main() {
// mee aqq
fmt.Println(findAndReplacePattern([]string{"abc","deq","mee","aqq","dkd","ccc"}, "abb"))
// all
fmt.Println(findAndReplacePattern([]string{"ef","fq","ao","at","lx"},"ya"))
}
func findAndReplacePattern(words []string, pattern string) [... |
// Package main ...
package main
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strings"
"github.com/go-rod/rod/lib/utils"
)
func main() {
cleanup()
comment := `// This file is generated by "./lib/proto/generate"`
schema := getSchema()
init := comment + utils.S(`
package proto
import (... |
package main
import (
"encoding/json"
"log"
"net/http"
"os"
"strconv"
"time"
"github.com/kelseyhightower/envconfig"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/stianeikeland/go-rpio/v4"
)
type config struct {
Pin int `required:"tr... |
package controllers
import (
"github.com/gin-gonic/gin"
"io/ioutil"
"log"
"net/http"
"os"
"potrcko/components/notify"
"potrcko/models"
"strconv"
)
func UsersImageGET(c *gin.Context) {
id := c.Param("id")
if id == "" {
c.AbortWithStatus(http.StatusNotFound)
return
}
dir, err := os.Getwd()
if err != n... |
package config
import (
"os"
log "github.com/sirupsen/logrus"
)
// set logger on global level
func InitLog() {
formatter := &log.TextFormatter{
FullTimestamp: true,
}
log.SetFormatter(formatter)
}
// GetNatsServer returns NATS servers to connect to e.g. [nats://localhost:4222,nats://localhost:4223,nats://loc... |
package restapi
import (
"encoding/json"
"net/http"
"github.com/adamluzsi/frameless/ports/crud"
"github.com/adamluzsi/frameless/ports/iterators"
)
type IndexOperation[Entity, ID, DTO any] struct {
BeforeHook BeforeHook
Override func(r *http.Request) iterators.Iterator[Entity]
}
func (ctrl IndexOperation[Ent... |
package main
import "fmt"
func main(){
str:="jin中国long"
fmt.Println(reverString(str))
}
//注意:需要判断是否含有中文
func reverString(str string) string{
if len(str)==0{
return ""
}
//不区分中英文
temp:=[]rune(str)
for i:=0;i<len(temp)/2;i++{
temp[i],temp[len(temp)-1-i]=temp[len(temp)-1-i],temp[i]
}
return string(temp)... |
package ion
import (
"strings"
"testing"
"time"
)
func TestParseTimestamp(t *testing.T) {
test := func(str string, eval string) {
t.Run(str, func(t *testing.T) {
val, err := parseTimestamp(str)
if err != nil {
t.Fatal(err)
}
et, err := time.Parse(time.RFC3339Nano, eval)
if err != nil {
t... |
// package service
import (
"agenda/entity"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
)
//存储用户信息
var user_info []entity.User
//log存储命令执行情况
var log_file *os.File
func Register(username, password, email, phone string) {
readFile()
logFile, _ := os.OpenFile("service/agenda.log", os.O_WRONLY|os.O_APPEND|os.... |
package valid_boomerang
const (
max = 2<<32 - 1
)
func isBoomerang(points [][]int) bool {
var samePoint bool
slopeValues := make([]float64, 3)
slopeValues[0], samePoint = calculateSlope(points[0], points[1])
if samePoint {
return false
}
slopeValues[1], samePoint = calculateSlope(points[1], points[2])
if... |
// 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 config
import (
"encoding/json"
"log"
"os"
)
type Configuration struct {
LbAddr string `json:"lb_addr"`
}
type Test struct {
Name string `json:"lb_addr"`
}
var configuration *Configuration
var test *Test
func init() {
file, _ := os.Open("../conf.json")
defer file.Close()
decoder := json.NewDecoder(... |
package db
import (
"fmt"
// blank import for MSSQL driver
_ "github.com/denisenkom/go-mssqldb"
)
type msSQLDialect struct {
baseDialect
}
const (
insertMigrationMSSQLDialectSQL = "insert into %v.%v (name, source_dir, filename, type, db_schema, contents, checksum) values (@p1, @p2, @p3, @p4, @p5, @p6, @p7)"
... |
package twitch
import (
"context"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
)
// UserList maps to json response from twitch
type UserList struct {
Data []User `json:"data"`
}
// User stores twitch user data
type User struct {
ID string `json:"id"`
Login string `json:"login"`
DisplayN... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.