text stringlengths 11 4.05M |
|---|
// 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 motioninput provides a representation of Android's MotionEvent, and allows communication
// with the test application ArcMotionInputTest.apk via a Tester. It also ... |
package api
import (
"github.com/google/uuid"
"github.com/jiangmitiao/cali/app/models"
"github.com/jiangmitiao/cali/app/rcali"
"github.com/revel/revel"
"strconv"
"time"
)
type User struct {
*revel.Controller
}
// /user
func (c User) Index() revel.Result {
return c.RenderJSONP(c.Request.FormValue("callback"),... |
package service
import (
"shopping-cart/types"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
func (suite *ServiceTestSuite) SetupTest() {
suite.clientMock = new(MockApiClient)
suite.serviceMock = new(MockApiService)
}
type ServiceTestSuite struct {
suite.Suite
clientM... |
package main
import ( "fmt" )
func main() {
var i *int
i = 70
i = method(&i)
fmt.Println(*i)
}
func method(i *int) *int {
&i = 7
return i
}
|
package exchange
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"math/rand"
"github.com/buger/jsonparser"
"github.com/prebid/go-gdpr/vendorconsent"
gpplib "github.com/prebid/go-gpp"
gppConstants "github.com/prebid/go-gpp/constants"
"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/pr... |
package database
import (
"encoding/json"
"log"
"os"
"gopkg.in/mgo.v2"
)
var DatabaseName string
var DatabaseSession *mgo.Session
var AdminCollection *mgo.Collection
var CourseCollection *mgo.Collection
var SubjectCollection *mgo.Collection
var FacultyCollection *mgo.Collection
var SectionCollection *mgo.Collec... |
package main
import (
"LeetCodeGo/base"
"LeetCodeGo/utils"
"log"
)
/*
给定一个二叉树,返回它的中序 遍历。
示例:
输入: [1,null,2,3]
1
\
2
/
3
输出: [1,3,2]
进阶: 递归算法很简单,你可以通过迭代算法完成吗?
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/binary-tree-inorder-traversal
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
*/
fu... |
/*
Copyright 2020 Rafael Fernández López <ereslibre@ereslibre.es>
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 o... |
// Copyright 2017 The EvAlgo 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 evhtml
var (
// DEBUG sets debuggin on or off
DEBUG = false
)
|
package ohdear
import (
"fmt"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/VictorAvelar/goh-dear/testdata"
)
func TestSitesSrv_Get(t *testing.T) {
setEnv()
setup()
defer func() {
tearDown()
unsetEnv()
}()
cases := []struct {
id uint
name string
status int
... |
// Copyright 2020 The Moov Authors
// Use of this source code is governed by an Apache License
// license that can be found in the LICENSE file.
package camt_v07
import (
"reflect"
"github.com/moov-io/iso20022/pkg/utils"
)
// Must be at least 1 items long
type ExternalAccountIdentification1Code string
func (r Ex... |
package main
import (
"fmt"
"github.com/gashjp/hellogo"
)
func main() {
fmt.Println(hello_lib.World())
}
|
package pem
import (
"bytes"
"crypto/ed25519"
"crypto/x509"
"encoding/pem"
"fmt"
"os"
"path"
"github.com/pkg/errors"
"github.com/iotaledger/hive.go/runtime/ioutils"
)
// ReadEd25519PrivateKeyFromPEMFile reads an Ed25519 private key from a file with PEM format.
func ReadEd25519PrivateKeyFromPEMFile(filepath... |
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/swag"
strfmt "... |
package cryptdo
import (
"crypto/rand"
"errors"
"fmt"
"io"
"github.com/golang/protobuf/proto"
"code.xoeb.us/cryptdo/cryptdo/cryptdopb"
)
const currentVersion = 1
// ErrEmptyMessage is caused by trying to decrypt and empty function.
var ErrEmptyMessage = errors.New("cryptdo: empty message")
// Encrypt takes ... |
package schema
// LoginParam 登录参数
type LoginParam struct {
UserName string `json:"username" binding:"required" swaggo:"true,用户名"`
Password string `json:"password" binding:"required" swaggo:"true,密码(md5加密)"`
}
// User 用户对象
type UserParam struct {
UserId string `json:"user_id" swaggo:"false,记录ID"`
UserName string... |
package app
import (
"log"
"path/filepath"
"strings"
"github.com/spf13/viper"
)
// Initialize config.toml config. Fatal if not exist.
func InitConfig(f string) {
name, dir, ext := filepath.Base(f), filepath.Dir(f), filepath.Ext(f)
name = strings.TrimSuffix(name, ext)
viper.SetConfigName(name)
viper.AddConfi... |
package entity
type StateType string
const (
Regular StateType = "Regular" // Обычный (значение по умолчанию)
Successful StateType = "Successful" // Финальный положительный
Unsuccessful StateType = "Unsuccessful" // Финальный отрицательный
)
// State Статус договра
type State struct {
Meta *M... |
// +build windows
package ConsoleColor
import (
"fmt"
)
func Print(c int, a ...interface{}) (int, error) {
if GetOS() == OS_WINDOWS {
defer locker.Unlock()
defer ResetColor()
locker.Lock()
fc := GetForegroundColor(OS_WINDOWS, c)
Textbackground(fc)
}
return fmt.Print(a...)
}
func Printf(c int, format s... |
package gio
import (
exp "github.com/jholowczak/guacamole_client_go"
"github.com/jholowczak/guacamole_client_go/gprotocol"
)
// GuacamoleWriter Provides abstract and raw character write access
// to a stream of Guacamole instructions.
type GuacamoleWriter interface {
// WriteEx function
// * Writes a portion of ... |
package raws // import "github.com/BenLubar/dfide/gui/raws"
import (
"bytes"
"log"
"github.com/BenLubar/dfide/gui"
"github.com/BenLubar/dfide/raws"
)
type visualEditor interface {
control() gui.Control
setName(string)
OnChange(func([]byte))
}
type baseVisualEditor struct {
listeners []func([]byte)
name ... |
package warning
import (
"github.com/go-gorp/gorp"
"github.com/ovh/cds/engine/api/application"
"github.com/ovh/cds/engine/api/environment"
"github.com/ovh/cds/engine/api/pipeline"
"github.com/ovh/cds/engine/api/workflow"
"github.com/ovh/cds/sdk/log"
)
func variableIsUsed(db gorp.SqlExecutor, key string, varNam... |
package main
import (
"freshdesk/server"
"net/http"
"github.com/joho/godotenv"
"github.com/sirupsen/logrus"
)
func init() {
// loads values from .env into the system
/*
Expected env variables:
API_URL=<https://domain.freshdesk.com/api/v2/>
API_KEY=<key>
API_LOC=<timezone, eg America/New_York>
ALL... |
// 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"
"os"
"time"
"chromiumos/tast/common/testexec"
"chromiumos/tast/errors"
"chromiumos/tast/local/chrome/uiauto"
"chromiumos/tast/loc... |
// Copyright 2016 Amazon.com, Inc. or its affiliates. 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. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// Unless required by appl... |
package mediators
import (
"app/models"
"github.com/gin-gonic/gin"
. "app/helpers"
)
type postsMediator struct {
Posts *models.Posts
Context *gin.Context
Collection []*models.Post
}
func (self *postsMediator) Find() (*CR, error) {
var err error
self.Collection, err = self.Posts.Find()
return ... |
package orb
import (
"fmt"
)
// Equal returns if the two geometrires are equal.
func Equal(g1, g2 Geometry) bool {
if g1 == nil || g2 == nil {
return g1 == g2
}
if g1.GeoJSONType() != g2.GeoJSONType() {
return false
}
switch g1 := g1.(type) {
case Point:
return g1.Equal(g2.(Point))
case MultiPoint:
... |
package matcher
import (
"context"
"fmt"
"os/exec"
"regexp"
"strings"
"time"
log "github.com/sirupsen/logrus"
"gitlab.com/yakshaving.art/chief-alert-executor/internal"
"gitlab.com/yakshaving.art/chief-alert-executor/internal/metrics"
)
// New creates a new Matcher with the provided configuration.
//
// May... |
package test
import (
"encoding/json"
"net/http"
"testing"
"time"
"github.com/HDIOES/su4na-API-main/integration"
"github.com/HDIOES/su4na-API-main/models"
"github.com/HDIOES/su4na-API-main/rest"
"github.com/HDIOES/su4na-API-main/rest/util"
"github.com/gorilla/mux"
"github.com/pkg/errors"
"github.com/stretc... |
// 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 wm provides Window Manager Helper functions.
package wm
import (
"context"
"math"
"time"
"chromiumos/tast/common/android/ui"
"chromiumos/tast/errors"
"chro... |
package openrtb_ext
import "fmt"
const DefaultBidLimit = 1
const MaxBidLimit = 9
func ValidateAndBuildExtMultiBid(prebid *ExtRequestPrebid) ([]*ExtMultiBid, []error) {
if prebid == nil || prebid.MultiBid == nil {
return nil, nil
}
var validationErrs, errs []error
var validatedMultiBids, newMultiBids []*ExtMul... |
package main
import "fmt"
/*
考点:
for range循环,会创建每个元素的副本,所以v的地址是相同的
range 表达式复制一个副本_, v := range slice, 这里的slice是副本引用
*/
func main() {
slice := []int{1,2,3,4}
//这里的v是循环对象每个元素的副本
for _, v := range slice {
fmt.Printf("%p\n", &v)
fmt.Println(v)
}
m := make(map[int]*int)
for key, val:= range slice {
//将... |
package bindings
import (
"os"
"path/filepath"
"reflect"
"strings"
"github.com/containers/podman/v3/pkg/bindings/containers"
"github.com/containers/podman/v3/pkg/bindings/images"
"github.com/containers/podman/v3/pkg/specgen"
)
func (p *PodmanClient) PullImage(nameOrID string) (*PullImageReport, error) {
var ... |
package main
import(
"fmt"
log "github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
"gopkg.in/yaml.v2"
"github.com/armon/consul-api"
"os"
"io/ioutil"
)
//Connect establishes a connection to local running consul agent.
//Currently only localhost:8500 is supported.
func Connect() *consulapi.Client {
cli... |
package odoo
import (
"fmt"
)
// BaseImportTestsModelsM2ORequired represents base_import.tests.models.m2o.required model.
type BaseImportTestsModelsM2ORequired struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlrpc:"cr... |
package pluginregistry
import "github.com/janoszen/exoscale-account-wiper/plugin"
func New() *PluginRegistry {
return &PluginRegistry{
plugins: []plugin.DeletePlugin{},
pluginsByKey: make(map[string]plugin.DeletePlugin),
enabledPlugins: make(map[string]bool),
}
}
|
package main
import (
"fmt"
"math"
"sort"
"strings"
"testing"
)
func TestPackageProblem(t *testing.T) {
for k, v := range map[string]string{
"81 : (1,53.38,$45) (2,88.62,$98) (3,78.48,$3) (4,72.30,$76) (5,30.18,$9) (6,46.34,$48)": "4",
"8 : (1,15.3,$34)": "-",
"75 : (1,85.31,$29) (2,14.55,$74) (3,3.98,$16... |
package geometry
import (
"math"
"testing"
)
const (
x = 4.5
y = 2.4
z = 3.4
x2 = 8.7
y2 = 1.4
z2 = 3.1
)
func CreateVector() *Vector {
v := new(Vector)
v.x = x
v.y = y
v.z = z
return v
}
func CreateVector2() *Vector {
v := new(Vector)
v.x = x2
v.y = y2
v.z = z2
return v
}
func TestCreateV... |
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
)
// GetJdbcDriversHipermediaRepresentationReader is a Reader for the GetJd... |
// 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 ash
import (
"context"
"chromiumos/tast/local/chrome"
)
// ClipboardTextData returns clipboard text data.
func ClipboardTextData(ctx context.Context, tconn *chro... |
package proteus
// Wrapper is now a no-op func that exists for backward compatibility. It is now deprecated and will be removed in the
// 1.0 release of proteus.
func Wrap(sqle Wrapper) Wrapper {
return sqle
}
|
package audit
import (
"fmt"
"math"
"net/http"
"net/http/httptest"
"net/url"
"sort"
"strconv"
"strings"
"testing"
"github.com/google/uuid"
"github.com/jrapoport/gothic/config"
"github.com/jrapoport/gothic/core/audit"
"github.com/jrapoport/gothic/core/context"
"github.com/jrapoport/gothic/hosts/rest"
"g... |
package store
import (
"context"
"errors"
"testing"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/ssm/ssmiface"
"github.com/aws/aws-sdk-go/service/ssm"
)
var (
past, _ = time.Parse("Mon, 01/02/06, 03:04PM", "Thu, 05/19/11, 10:47PM")
)
fun... |
package routing
import (
"allbooks/models"
"fmt"
"net/url"
"strconv"
"strings"
)
const (
MaxPerPage = 200
)
func makeLink(
context *CollectionContext, page uint64, perPage uint64, rel string,
) string {
strPage := strconv.FormatUint(page, 10)
strPerPage := strconv.FormatUint(perPage, 10)
Url, err := url.P... |
// 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 singleton
import "testing"
func TestSingleton(t *testing.T) {
a := GetInstance()
b := GetInstance()
if a != b {
t.Errorf("different")
}
}
|
// Copyright 2017 Zhang Peihao <zhangpeihao@gmail.com>
package serialize
import (
"bufio"
"bytes"
"io"
"github.com/golang/glog"
"github.com/zhangpeihao/zim/pkg/define"
"github.com/zhangpeihao/zim/pkg/protocol"
)
// ParseEngine 解析引擎函数
type ParseEngine interface {
Parse(br *bufio.Reader) (cmd *protocol.Command... |
package zone
import (
"github.com/pkg/errors"
"github.com/kumahq/kuma/pkg/tokens/builtin/zoneingress"
"github.com/kumahq/kuma/pkg/config/core/resources/store"
"github.com/kumahq/kuma/pkg/core/runtime/component"
"github.com/kumahq/kuma/pkg/kds/mux"
kds_server "github.com/kumahq/kuma/pkg/kds/server"
resources_k... |
package main
import (
"strings"
"time"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
"github.com/sirupsen/logrus"
)
func (c *Config) mGUI(m string) *fyne.Container {
date := widget.NewEntry()
date.SetText(time.Now().Format("2006-01-02"))
song1box := widget.NewEntry()
song1box.Set... |
package rest
import (
"encoding/json"
"githubapi-golang/domain"
"net/http"
)
type getRequest struct {
endPoint string
}
func NewGetRequest(endPoint string) domain.GetRequest {
return &getRequest{
endPoint: endPoint,
}
}
func (g *getRequest) GetUser(username string) domain.UserInfo {
var u domain.UserInfo
... |
package main
import (
"testing"
"github.com/360EntSecGroup-Skylar/excelize"
"fmt"
)
func TestPathWrt(t *testing.T) {
xlsx := excelize.NewFile()
// Create a new sheet.
index := xlsx.NewSheet("Sheet2")
// Set value of a cell.
xlsx.SetCellValue("Sheet2", "A2", "Hello -- world.")
xlsx.SetCellValue("Sheet1", "B2"... |
package voucher
import (
"github.com/stretchr/testify/suite"
"testing"
)
type TenantSuite struct {
suite.Suite
}
func (s *TenantSuite) TestAccept() {
}
func (s *TenantSuite) TestAcceptRequest() {
}
func (s *TenantSuite) TestRevert() {
}
func TestTenantSuite(t *testing.T) {
suite.Run(t, &TenantSuite{})
}
|
package requests
import (
"fmt"
"net/url"
"strings"
"github.com/atomicjolt/canvasapi"
)
// PublishProvisionalGradesForAssignment Publish the selected provisional grade for all submissions to an assignment.
// Use the "Select provisional grade" endpoint to choose which provisional grade to publish
// for a partic... |
package main
import (
"fmt"
"reflect")
func main() {
//test_reference()
//test_ptr()
//test_struct()
//test_array()
//test_types()
//test_slice_capacity()
//test_copy_on_capacity_overload()
test_looping()
}
func test_types() {
var a = [1]string{"Hello"} // this defines a... |
package odoo
import (
"fmt"
)
// BaseModuleUpgrade represents base.module.upgrade model.
type BaseModuleUpgrade struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
DisplayName *String `xml... |
// Copyright 2020 Paul Greenberg greenpau@outlook.com
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applic... |
package main
import (
"fmt"
"math"
)
const factors = 500
func main() {
n := uint64(0)
for i := uint64(1); ; i++ {
n += i
count := numFactors(n)
if count >= factors {
fmt.Println("found it:", n)
break
}
}
}
func numFactors(n uint64) int {
count := 0
for i := uint64(1); i <= uint64(math.Floor(mat... |
package jobseekerprofile
import (
"excho-job/entity"
"gorm.io/gorm"
)
type Repository interface {
FindByUserID(ID string) (entity.JobSeekerProfile, error)
Create(jobSeekerProfile entity.JobSeekerProfile) (entity.JobSeekerProfile, error)
UpdateByID(ID string, dataUpdate map[string]interface{}) (entity.JobSeekerP... |
package main
import (
"bufio"
"flag"
"fmt"
"log"
"os"
"strconv"
)
func main() {
// Flag handling
inpath := flag.String("i", "", "Path to input file containing line seperated data")
outpath := flag.String("o", "", "Path to output file where results will be stored")
stressrange := flag.Float64("r", 10.0, "Th... |
package parser
import (
"bufio"
"bytes"
"errors"
"io"
)
// Lexer is a lexer
type Lexer struct {
r *bufio.Reader
ch chan Token
lines []int
column int
lastRuneSize int
}
func NewLexer(r io.Reader) *Lexer {
return &Lexer{
r: bufio.NewReader(r),
ch: make(chan Token),
}
}... |
package transfer
//
// 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 l... |
// Copyright 2018 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 w... |
package errors
import (
std_errors "errors"
"fmt"
)
// New returns a new error with a message and a stack.
func New(msg string) error {
err := std_errors.New(msg)
err = withStack(err, 2)
return err
}
// Errorf returns a new error with a formatted message and a stack.
func Errorf(format string, args ...interface... |
package tg
import (
"log"
"strings"
"unicode"
)
type CommandHandler func(b *CommandBot, args string, msg *Message)
type AnyCommandHandler func(b *CommandBot, cmd, args string, msg *Message)
// CommandBot only handles commands.
type CommandBot struct {
*Bot
Handlers map[string][]CommandHandler
AnyHandlers []... |
/*
Copyright © 2021 NAME HERE <EMAIL ADDRESS>
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 diff
import (
"github.com/containerum/kube-client/pkg/model"
"github.com/ninedraft/boxofstuff/strset"
)
type ContainerSet map[ComparableContainer]model.Container
func NewContainerSet(containers []model.Container) ContainerSet {
var set = make(ContainerSet, len(containers))
for _, container := range conta... |
/*
Паттерн «Фабричный метод», является порождающим паттерном, т.е. отвечает за удобное и безопасное создание новых объектов или даже целых семейств объектов.
Он позволяет:
1) Определяет интерфейс для создания объекта, но оставляет подклассам решение о том, какой класс инстанцировать. Фабричный метод позволяет классу де... |
package main
import (
"fmt"
"reflect"
"unsafe"
)
func main() {
var str string
var s []int
var m map[string]int
var f func(int, int) int
var i interface{}
var c chan int
var ptr *int
fmt.Println(str == "")
fmt.Println(s == nil)
fmt.Println(m == nil)
fmt.Println(f == nil)
fmt.Println(i == nil)
fmt.Print... |
package e
var MsgFlags = map[int]string {
SUCCESS : "ok",
ERROR : "fail",
INVALID_PARAMS : "请求参数错误",
ERROR_AUTH_CHECK_TOKEN_TIMEOUT : "Token已超时",
ERROR_AUTH_TOKEN : "Token生成失败",
ERROR_AUTH : "Token错误",
ERROR_REGISTER_FORMAT_FAIL : "请求参数不符合格式",
ERROR_USER_EXIST : "注册失败,用户名已存在!",
ERROR_UPLOAD_SAVE_IMAGE_FAIL: ... |
package testlib
import (
"bytes"
"fmt"
"image/png"
"github.com/remogatto/imagetest"
"github.com/remogatto/mandala"
)
func (t *TestSuite) TestDraw() {
request := mandala.LoadResourceRequest{
Filename: "drawable/expected.png",
Response: make(chan mandala.LoadResourceResponse),
}
mandala.ResourceManager() ... |
package flags
import "strconv"
type Int64Value struct {
set bool
value int64
}
func (i *Int64Value) Set(s string) error {
v, err := strconv.ParseInt(s, 0, strconv.IntSize)
if err != nil {
err = numError(err)
}
i.value = v
i.set = true
return err
}
func (i *Int64Value) Get() interface{} { return i.value... |
package test
import (
"fmt"
"testing"
)
func TestRange(t *testing.T) {
nums := []int{1, 2, 3, 4}
sum := 0
for i, num := range nums {
sum += num
fmt.Println(i, sum)
}
kvs := map[string]string{"a": "1", "b": "2", "c": "3"}
for _, v := range kvs {
fmt.Printf("%s\n", v)
}
for _, v := range "abcdef" {
... |
package update_model
import (
"github.com/syou6162/go-active-learning/lib/classifier"
tweet_feature "github.com/syou6162/go-active-learning/lib/feature/tweet"
"github.com/syou6162/go-active-learning/lib/model"
"github.com/syou6162/go-active-learning/lib/service"
"github.com/urfave/cli"
)
func doUpdateTweetModel(... |
package main
import (
"github.com/notblizzard/bluebirdmini/Godeps/_workspace/src/github.com/gorilla/mux"
"net/http"
)
func main() {
r := mux.NewRouter()
r.HandleFunc("/", RootHandler)
r.HandleFunc("/new", NewHandler)
r.HandleFunc("/home", HomeHandler)
r.HandleFunc("/login", LoginHandler)
r.HandleFunc("/logou... |
// Copyright 2020 Comcast Cable Communications Management, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required ... |
package vehicle
import (
"time"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/vehicle/bluelink"
)
// https://github.com/Hacksore/bluelinky
// https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/pull/353/files
// Bluelink is an api.Vehicle implementation
type Bl... |
package main
// Leetcode 89. (medium)
func grayCode(n int) []int {
res := []int{0}
for i := 1; i <= n; i++ {
res = append(res, res...)
inc := len(res) / 2
left, right := inc-1, inc
for left >= 0 {
res[right] = res[left] + inc
left--
right++
}
}
return res
}
|
package client_test
import (
"github.com/farzadrastegar/simple-cab/gateway"
"github.com/farzadrastegar/simple-cab/gateway/client"
)
// Client represents a test wrapper for client.Client.
type Client struct {
*client.Client
cabService gateway.CabService
Handler *Handler
}
// NewClient returns a new instance ... |
package user
import "github.com/zxhaaa6/gin-demo/model"
type Service struct {
UserDao Dao
}
func InitService() Service {
service := Service{}
service.UserDao = InitDao()
return service
}
func (r *Service) findUserById(id string) (model.User, error) {
return r.UserDao.findUserById(id)
}
func (r *Service) getAl... |
package main
import (
"fmt"
"net/http"
"math"
"math/rand"
"bufio"
"os"
)
// pi launches n goroutines to compute an
// approximation of pi.
func pi(n int) float64 {
f := 0.0
for k := 0; k <= n; k++ {
f += 4 * math.Pow(-1, float64(k)) / (2*float64(k) + 1)
}
return f
}
func cpuLoad() string {
return fmt.S... |
// Copyright 2015 The Vanadium 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 tool
import (
"io"
"os"
"v.io/jiri/gerrit"
"v.io/jiri/gitutil"
"v.io/jiri/jenkins"
"v.io/jiri/runutil"
"v.io/x/lib/cmdline"
"v.io/x/lib/... |
package config
// Reference: https://github.com/prometheus/prometheus/blob/76cd5f4c7f123041525f101611a2cc04fd3d5382/config/config.go#L138
import (
"io/ioutil"
"github.com/pkg/errors"
"gopkg.in/yaml.v2"
)
var (
// DefaultConfig is the config with parsing config.yaml
DefaultConfig = config{}
)
func init() {
lo... |
// Copyright (c) Jeevanandam M. (https://github.com/jeevatkm)
// go-aah/aah source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.
package aah
import (
"encoding/json"
"encoding/xml"
"errors"
"fmt"
"html/template"
"io"
"os"
"path/filepath"
"strings"
"sync"
"aahf... |
package v1
import (
"context"
"errors"
"fmt"
"io"
"time"
"github.com/h2non/filetype"
"github.com/h2non/filetype/matchers"
"github.com/traPtitech/trap-collection-server/src/domain"
"github.com/traPtitech/trap-collection-server/src/domain/values"
"github.com/traPtitech/trap-collection-server/src/repository"
... |
package main
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"strings"
"time"
"github.com/jxmoore/testFlightBuildAutomation/models"
)
func processNewBuild() error {
var slackMsg string
fmt.Printf("Begining to process new build.\n Current flags are : \nBuildNumber :%v\nBuildVersion:... |
package cmd
import (
"fmt"
"strings"
"github.com/fugue/fugue-client/client/environments"
"github.com/fugue/fugue-client/format"
"github.com/fugue/fugue-client/models"
"github.com/spf13/cobra"
)
type createGoogleEnvironmentOptions struct {
Name string
ServiceAccountEmail string
ProjectID ... |
package util_test
import (
"net/http"
"testing"
"goscrum/server/util"
"github.com/pkg/errors"
. "github.com/smartystreets/goconvey/convey"
)
func TestRedirect(t *testing.T) {
Convey("Response -> Redirect", t, func() {
res, err := util.Redirect("test.png")
So(res.StatusCode, ShouldEqual, http.StatusTempora... |
// 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 proto
import (
"packet"
)
type MsgSceneRotPos struct {
rotX int16
rotY int16
rotZ int16
posX int16
posY int16
posZ int16
}
func (this *MsgSceneRotPos) Encode() []byte ... |
package main
import (
"encoding/xml"
"mime/multipart"
"reflect"
"strings"
"golang.org/x/net/context"
"github.com/PuerkitoBio/goquery"
"github.com/golang/glog"
)
type GoFeedParser struct {
FeedReader
}
func (e GoFeedParser) ParseFeed(ctx context.Context, feedFile multipart.File) {
e.waitGroup.Add(1)
e.par... |
//if else if else
package main
import "fmt"
func main() {
x := 66
if x == 66 {
fmt.Println("x = 66")
} else if x <= 65 {
fmt.Println("x <= 65")
} else {
fmt.Println("x not 66")
}
}
|
package admin
import (
"github.com/kataras/iris"
"github.com/mojocn/base64Captcha"
"iris_test/models"
"iris_test/common"
)
type CaptchaResponse struct {
CaptchaId string `json:"captchaId"` //验证码Id
ImageUrl string `json:"imageUrl"` //验证码图片url
}
//登录
func Login(c iris.Context){
if(c.Method() == "POST"){
idK... |
package main
import (
"html/template"
"log"
"os"
)
type Page struct {
Title string
}
var templates = template.Must(template.ParseGlob("templates/*"))
func main() {
p := Page{Title: "Heading"}
err := templates.ExecuteTemplate(os.Stdout, "template.html", p)
if err != nil {
log.Fatal("Cannot Get View", err)
... |
package mb
import (
"context"
"crypto/rand"
"encoding/base64"
"fmt"
"io"
"net/http"
"net/http/cookiejar"
"net/url"
"strings"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/request"
cv "github.com/nirasan/go-oauth-pkce-code-verifier"
"golang.org/x/net/publicsuffix"
"golang.org/x/oauth2"
)
... |
package Controller
import (
"1/Model"
_struct "1/struct"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
"os"
"strconv"
)
func CreatVideo(context *gin.Context) {
var video _struct.Video
err := context.ShouldBind(&video);if err!=nil{
context.String(5000,"绑定失败")
return
}
//读取上传的视频
v,err :=context.FormFile... |
/*
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 writing, soft... |
// Copyright 2017 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 dotslash
import (
"./simple"
)
var (
A = simple.A
)
|
package ghost
import (
"bytes"
"encoding/json"
"fmt"
"github.com/shihtzu-systems/bright/pkg/bungo"
"github.com/shihtzu-systems/bright/pkg/tower"
log "github.com/sirupsen/logrus"
"strings"
)
func NewGhost(id, sessionId string) Ghost {
return Ghost{
Id: id,
SessionId: sessionId,
}
}
func (g *Ghost... |
package main
import (
"flag"
"fmt"
"os"
)
//包被导入时会被调用init函数,只会执行一次
func init() {
//自定义命令源码文件的参数使用说明
//flag.Usage的类型是func(),即一种无参数声明且无结果声明的函数类型
//flag.Usage变量在声明时就已经被赋值了
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage of %s:\n", "question")
//用于打印需要输入参数的说明
flag.PrintDefaults()
}
}
func main() {
//... |
package v2
import (
"bytes"
"context"
"fmt"
"github.com/grafana/tempo/pkg/sort"
"github.com/cespare/xxhash"
"github.com/grafana/tempo/tempodb/backend"
"github.com/grafana/tempo/tempodb/encoding/common"
"github.com/opentracing/opentracing-go"
)
type indexReader struct {
r backend.ContextReader
recor... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.