text
stringlengths
11
4.05M
// Licensed to Elasticsearch B.V. under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. Elasticsearch B.V. licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use ...
package main import ( "MyCart/cmd/Services" "errors" "fmt" "testing" ) func TestAddProduct(t *testing.T) { var tests = []struct { userValue string userName string expected error }{ {"Shirt", "Linu", nil}, //Already Prsent User {"qwert", "Linu", errors.New("Sorry!! Entered Product is not present")},...
package main import ( "log" "net/http" "github.com/gorilla/mux" ) func buildCityController(usecase *cityUseCase, cityPresenter *cityPresenter, errorPresenter *errorPresenter) func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) { params := mux.Vars(r) defer func...
package service import ( entity "github.com/Surafeljava/Court-Case-Management-System/Entity" "github.com/Surafeljava/Court-Case-Management-System/caseUse" ) type AdminCourtServiceImpl struct { courtRepo caseUse.CourtRepository } func NewAdminCourtServiceImpl(csRepo caseUse.CourtRepository) *AdminCourtServiceImpl ...
package servers import ( "time" ) type CreateServerReq struct { Nane string Description string GroupId string SourceServerId string IsManagedOS bool PrimaryDns string SecondaryDns string IpAddress string Password s...
package base import ( "context" "net" "strings" "testing" "time" ) type dialer struct { } func (d dialer) Dial(network, address string) (net.Conn, error) { return net.Dial(network, address) } func TestOutputMinerRPC(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() var...
package client import ( "fmt" "sync" "github.com/Mvilstrup/mosquito/communication/errors" "github.com/Mvilstrup/mosquito/communication/messages" zmq "github.com/alecthomas/gozmq" ) // A Coordinator defines the parameters for running a web crawler. type Client struct { // ZeroMQ specific variables id str...
package goosedb import ( "database/sql" "errors" "fmt" "path/filepath" "sort" "github.com/kevinburke/goose/lib/goose" _ "github.com/go-sql-driver/mysql" _ "github.com/lib/pq" _ "github.com/mattn/go-sqlite3" _ "github.com/ziutek/mymysql/godrv" ) var ErrTableDoesNotExist = errors.New("goosedb: table does no...
package resource import ( "testing" "time" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1" ) func TestDurationForPod(t *testing.T) { now := time.No...
package common type PageInfo struct { TotalPages int32 TotalCount int32 }
package projection import ( "bytes" "github.com/satori/go.uuid" "github.com/tobyjsullivan/ues-command-api/passwords" ) type EmailIdentity struct { ID uuid.UUID Email string PasswordHash []byte PasswordHashAlgorithm string PasswordSalt []byte } func (id *E...
package di import ( "fmt" "reflect" "github.com/teamlint/container/di/internal/dag" "github.com/teamlint/container/di/internal/reflection" ) // New create new container. func New() *Container { return &Container{ graph: dag.NewDirectedGraph(), providers: make(map[key]provider), history: &provideHist...
package gen import ( "bufio" "bytes" "fmt" "go/ast" "go/parser" "go/printer" "go/token" "io" "log" "os" "path/filepath" "sort" "strings" ) // I tried to do this the "right" way using go/parser but ran into various strange behavior; // I probably just am missing something with how to use it properly. Reg...
// Copyright (c) 2016, Gerasimos Maropoulos // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of c...
package pgsql import ( "database/sql" "database/sql/driver" "strconv" ) // Int2VectorFromIntSlice returns a driver.Valuer that produces a PostgreSQL int2vector from the given Go []int. func Int2VectorFromIntSlice(val []int) driver.Valuer { return int2VectorFromIntSlice{val: val} } // Int2VectorToIntSlice returns...
package object import ( dstore "cloud.google.com/go/datastore" "github.com/golang/protobuf/proto" pb "github.com/pizzahutdigital/storage/protobufs" "github.com/pizzahutdigital/storage/storage" ) // Object implements Item type Object struct { id string value []byte timestamp int64 keys map[stri...
package main import ( "odbcstream/odbcstream" // "fmt" ) func main() { odbcstream.InitialiseDBConnection("psql", "france") // fmt.Println("Hello Go") }
package repo import ( "errors" "fmt" "strings" ) // Parse parses a repository name in the format 'owner/repo'. func Parse(value string) (*Repo, error) { parts := strings.Split(value, "/") if len(parts) != 2 { return nil, errors.New("repository must be in the form owner/repo") } owner := parts[0] if owner =...
package service import ( "../model" "../repository" "errors" "golang.org/x/crypto/bcrypt" ) type IUserDataService interface { AddUser(*model.User) (int64, error) DeleteUser(int64) error UpdateUser(user *model.User, isChangePwd bool) (err error) FindUserByName(string) (*model.User, error) CheckPwd(userName st...
package pipelineexecution import ( "github.com/rancher/rancher/pkg/pipeline/utils" "github.com/pkg/errors" "github.com/rancher/rancher/pkg/controllers/user/nslabels" images "github.com/rancher/rancher/pkg/image" "github.com/rancher/rancher/pkg/randomtoken" "github.com/rancher/rancher/pkg/ref" mv3 "github.com/r...
/***************************************************************** * Copyright©,2020-2022, email: 279197148@qq.com * Version: 1.0.0 * @Author: yangtxiang * @Date: 2020-08-17 15:52 * Description: *****************************************************************/ package xhttpServer import ( "fmt" "github.com/go-xe2/...
package Problem0726 import ( "sort" "strconv" ) func countOfAtoms(formula string) string { return parse(count(formula)) } func count(formula string) map[string]int { rec := make(map[string]int, len(formula)/2) var update = func(newRec map[string]int, times int) { for atom, c := range newRec { rec[atom] += ...
package cpu import ( "encoding/hex" "fmt" logger2 "github.com/vfreex/gones/pkg/emulator/common/logger" "github.com/vfreex/gones/pkg/emulator/memory" ) const ( SP_BASE uint16 = 0x100 ) type Cpu struct { // registers PC ProgramCounter P ProcessorStatus SP StackPointer A Accumulator X, Y IndexRegis...
package example import ( "github.com/catmorte/go-inversion_of_control/pkg/context" ) func init() { context.SetContext(context.NewMemoryContext()) }
package boilerplateapi import ( "os" "testing" ) type testRecord struct { Name string `json:"name"` Comment string `json:"comment"` } // TestLoadBoltstore Kicks the tires on the bolt store func TestLoadBoltstore(t *testing.T) { boltPath := "./test.boltdb" if _, err := os.Stat(boltPath); os.IsExist(err) { ...
package util import ( "bytes" "crypto/aes" "crypto/cipher" "crypto/rand" "encoding/hex" "fmt" "io" mrand "math/rand" "time" p "github.com/halivor/common/golang/packet" _ "github.com/halivor/goutil/bufferpool" ) var KEY = "" func InitCrypto(key string) { KEY = key } func GeneToken(uid int64) *p.Token { ...
package main import ( "flag" notify "tpay_backend/payapi/internal/order_notify" "tpay_backend/payapi/internal/common" "tpay_backend/payapi/internal/config" "tpay_backend/payapi/internal/crontab" "tpay_backend/payapi/internal/handler" "tpay_backend/payapi/internal/svc" "tpay_backend/utils" "github.com/tal-te...
package authapi // Success response // swagger:response ok type swaggOKResp struct{} // Error response // swagger:response err type swaggErrResp struct{} // Error response with message // swagger:response errMsg type swaggErrMsgResp struct { Message string `json:"message"` }
// Copyright 2019 Kuei-chun Chen. All rights reserved. package analytics import ( "bufio" "encoding/json" "errors" "fmt" "io" "io/ioutil" "log" "os" "path/filepath" "runtime" "sort" "strings" "time" "github.com/simagix/gox" "github.com/simagix/keyhole/ftdc" "github.com/simagix/keyhole/mdb" "go.mongo...
/* Copyright IBM Corp. 2016 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 agreed to in wri...
package main /* @Time : 2020-03-27 01:06 @Author : audiRStony @File : 13_file_buffio.go @Software: GoLand */ import ( "fmt" "bufio" "os" "io" ) func main() { file,err := os.Open("./zzh.txt") if err != nil{ fmt.Println("打开文件失败") return } defer file.Close() reader :=...
package main import ( "fmt" "io/ioutil" "log" "os" "text/template" "github.com/getkin/kin-openapi/openapi3" "github.com/ohatakky/openapi3markdown/template_md" ) const ( dir = "template_md/md/" outDir = "Docs/" ) var ( swagger *openapi3.Swagger Template *template.Template files []string = []string...
package main import ( "code.google.com/p/freetype-go/freetype" "code.google.com/p/freetype-go/freetype/truetype" //"database/sql" "fmt" "github.com/coopernurse/gorp" "github.com/vdobler/chart" "github.com/vdobler/chart/imgg" "image" "image/color" "image/draw" "image/png" "io/ioutil" "log" "os" "path/fil...
package main import ( "context" "fmt" "github.com/aws/aws-lambda-go/events" "github.com/aws/aws-lambda-go/lambda" "github.com/aws/aws-lambda-go/lambdacontext" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/cloudwatchlogs" "github.com/aws/aws-sdk-go/s...
package local import ( "bufio" "fmt" "os" "reflect" "strconv" "strings" ) // Tags are the permitted tags within a test file type Tags struct { Name string `rt:"NAME"` Summary string `rt:"SUMMARY"` Author string `rt:"AUTHOR,allowmultiple"` Labels string `rt:"LABELS"` Repeat int `rt:"REPEAT"` Issue...
package faiss import ( "context" "github.com/jplu/visual-search-backend/domain" "github.com/jplu/visual-search-backend/uc" "google.golang.org/grpc" "log" "strconv" ) // Faiss type type Faiss struct { client FaissServiceClient } // NewFaissClient creates a new gRPC client func NewFaissClient(addr string, port ...
package integration_test import ( "github.com/APTrust/exchange/constants" "github.com/APTrust/exchange/models" "github.com/APTrust/exchange/util" "github.com/APTrust/exchange/util/storage" "github.com/APTrust/exchange/util/testutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "pa...
package monitors import ( "github.com/go-ping/ping" ) func icmpMonitor(url string, expectation string) bool { pinger, err := ping.NewPinger(url) if err != nil { return false } pinger.Count = 1 pinger.Run() stats := pinger.Statistics() if stats.PacketLoss > 0.0 { return false } return true }
// Copyright 2023 Google LLC. 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 applica...
package ddl import ( "reflect" "strings" ) // Reserved words const ( Tag_Ddl = "ddl" Tag_Skip = "-" Tag_Col = "col" Tag_Key = "key" Tag_Auto = "auto" Tag_Inc = "inc" Tag_Ref = "ref" ) // Field attributes const Field_Skip = 0 const ( Field_Col = 1 << iota Field_Key Field_Auto Field_Inc Field_Ref ) ...
package c31_hmac_sha1_timing_leak import ( "math/rand" "testing" "time" "github.com/vodafon/cryptopals/set1/c1_hex_to_base64" ) func TestServer(t *testing.T) { key := make([]byte, 20+rand.Intn(100)) rand.Read(key) hs := NewHMACSystem(key) dur := 1 * time.Millisecond server := NewServer(hs, dur) fn := "foo...
/* 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, software distributed under the License ...
package connection type Connection interface { Write(data []byte) (int, error) Read() ([]byte, error) Close() error CloseWrite() error } type Connector interface { Dial() (Connection, error) }
package app import ( "encoding/json" "fmt" "log" ) var ( name string = "-" version string = "-" ) type ApplicationRecord struct { Name string `json:"name"` Version string `json:"version"` } var application *ApplicationRecord func (app *ApplicationRecord) String() string { return fmt.Sprintf("Name: %s...
package server import ( "github.com/gin-gonic/gin" _ "github.com/go-sql-driver/mysql" "github.com/gomodule/redigo/redis" "github.com/spf13/viper" "visitor/app/server/router" "visitor/client/redis_client" ) func Init() *gin.Engine { //// 连接数据库 //_, err = gorm_client.Dial("mysql", viper.GetString("mysql.address...
package test import ( "fmt" "testing" ) type ( RedisClient struct { } ClassB struct { RedisClient } ) func NewClassA() RedisClient { b := RedisClient{} return b } func (r *RedisClient) Exec() { fmt.Println("A is called") } func (r *ClassB) Exec() { fmt.Println("B is called") r.RedisClient.Exec() } f...
package main import ( "errors" "fmt" "regexp" "strconv" ) /* stat ::= assign | if | for | funDecl | ret | funCall statlist ::= stat [statlist] if ::= 'if' exp '{' [statlist] '}' [else '{' [statlist] '}'] for ::= 'for' [assign] ';' [explist] ';' [assign] '{' [statlist] '}' type ::= 'int' | 'float' | 'b...
// Copyright 2022 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 ordercancelreplacerequest import ( "github.com/shopspring/decimal" "time" "github.com/quickfixgo/quickfix" "github.com/quickfixgo/quickfix/enum" "github.com/quickfixgo/quickfix/field" "github.com/quickfixgo/quickfix/fix40" "github.com/quickfixgo/quickfix/tag" ) //OrderCancelReplaceRequest is the fix40...
package postgres import ( "context" "errors" "github.com/jackc/pgx/v5" "github.com/pomerium/pomerium/pkg/cryptutil" ) var migrations = []func(context.Context, pgx.Tx) error{ 1: func(ctx context.Context, tx pgx.Tx) error { _, err := tx.Exec(ctx, ` CREATE TABLE `+schemaName+`.`+recordsTableName+` ( type...
// Copyright 2023 Google LLC. 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 applica...
// Copyright 2023 Google LLC. 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 applica...
// +build testnet package common import ( "math/big" "github.com/qlcchain/go-qlc/common/types" ) var ( // PoV Block Chain Params PovChainGenesisBlockHeight = uint64(0) PovChainBlockInterval = 60 PovChainTargetCycle = 20 PovChainBlockSize = 2 * 1024 * 1024 PovChainRetargetTimespan = PovChainBlockI...
package handlers import ( "encoding/json" "fmt" "log" "net/http" "strconv" "gopkg.in/go-playground/validator.v9" "github.com/egamorim/star-wars-planets/cmd/api/request" "github.com/egamorim/star-wars-planets/cmd/api/response" "github.com/egamorim/star-wars-planets/pkg/integration" "github.com/gorilla/mux" ...
package repair import ( "strconv" "testing" ) // 10m ile 100m arasında olacak bir sayının md5 hali veriliyor, cevap olarak o sayı bekleniyor. func TestCheckRepair(t *testing.T) { results := []struct { Number int Md5Result string Result bool }{ {15765233, "2f0899f61805126a241830dc8f0b3d70", true}, ...
package main import ( "fmt" ) func main() { esporteFavorito := "starcraft" switch esporteFavorito { case "futebol": fmt.Println("quer jogar futebol, vai pro brasil") case "starcraft": fmt.Println("quer jogar starcraft, vai pra coréia") case "espeleísmo": fmt.Println("quer fazer essa coisa estranha, vai ...
package main import ( "fmt" "errors" ) func add(a, b int) (c int, err error) { if a<0 || b<0 { err = errors.New("XXXXX") return } a *= 2 b *= 3 c = a + b return } func main() { a, b := 1, 2 c, err := add(a,b) if err != nil { fmt.Println(err) } else { fmt.Printf("add(%d,%d)=%d\n",a,b,c) } }
package philifence type Properties map[string]interface{} type PointMessage struct { Type string `json:"type"` Properties Properties `json:"properties"` Geometry PointGeometry `json:"geometry"` } type PointGeometry struct { Type string `json:"type"` Coordinates []float64 `json:"coord...
package gorilla import ( "github.com/Highway-Project/highway/pkg/router" "github.com/Highway-Project/highway/pkg/rules" "github.com/gorilla/mux" "net/http" ) type GorillaRouter struct { router *mux.Router } func (r *GorillaRouter) AddRule(rule rules.Rule) error { route := r.router.Schemes(rule.Schema).PathPref...
package main import ( "fmt" ) type ErrNegativeSqrt float64 func(e ErrNegativeSqrt) Error() string{ return fmt.Sprintf("Cannot Sqrt negative number") } func Sqrt(x float64) (float64, error) { if x<0{ return x, ErrNegativeSqrt(x) } z:=1.0 for i:=0; i<10; i++{ z-=(z*z-x)/(2*z) } return z, nil } func main()...
// Package windowmean provides a moderately efficient implementation of a movingmean. package windowmean // WindowMean gives the window-based mean of a slice of float64's // using a window of the given radius. func WindowMean(a []float64, radius int) []float64 { var s float64 b := make([]float64, len(a)) for i := 0...
package crypto import ( "crypto-performance-compare/utils" "encoding/json" "fmt" "io/ioutil" "net/http" "time" ) type Client struct { baseURL string apiKey string baseCurrency string Cache *Cache } type Response struct { Symbol string `json:"symbol"` Name string `json:"name"` Price ...
package common import ( "bytes" "crypto/md5" "encoding/json" "fmt" "io/ioutil" "net/http" "strconv" "time" "tokensky_bg_admin/conf" ) //用户资产变动 type balanceChange struct { Uid int `json:"uid"` //货币类型 Symbol string `json:"symbol"` //操作 add加 sub减 mul乘法 qup除法 MethodBalance string `json:"methodBalanc...
package main import "testing" func TestFixUrl(t *testing.T) { var parameters = []struct { given string expected string }{ {"example.com", "https://example.com"}, {"http://example.com", "http://example.com"}, {"http://example.com/", "http://example.com"}, {"https://example.com/", "https://example.com"...
/* Copyright 2021 apstndb. 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, software distri...
package asyncexec import ( "fmt" "os" "os/exec" ) // StreamCommand executes a given command in a context directory and streams // the outputs to their according stdeout/stderr. func StreamCommand(workDir string, command string, args []string) error { cmd := exec.Command(command, args...) if workDir != "" { cmd...
package handler import ( "context" proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/core/v1" ) // WechatBuildOAuthURL 生成网页授权地址 func (j *JinmuHealth) WechatBuildOAuthURL(ctx context.Context, req *proto.WechatBuildOAuthURLRequest, resp *proto.WechatBuildOAuthURLResponse) error { w := j.wechat resp.A...
package dao import ( "github.com/jinzhu/gorm" ) type IDAware interface { GetID() interface{} SetID(id interface{}) } type BaseDAO struct { ConnectionManager ConnectionProvider Model interface{} } type DAO interface { Delete(object IDAware, tx ...*gorm.DB) error DeleteByID(id interface{}) Insert(...
package main import ( "fmt" "log" "net/http" "strconv" ) func main() { http.HandleFunc("/", set) http.Handle("/favicon.ico", http.NotFoundHandler()) http.ListenAndServe(":8080", nil) } func set(w http.ResponseWriter, r *http.Request) { // look for cookie first c, err := r.Cookie("stephens-cookie") if e...
package session import ( "bytes" "encoding/gob" "errors" "time" "github.com/boltdb/bolt" ) /* BoltStore is a session storage using bolt. */ type BoltStore struct { store *bolt.DB lastUsedName []byte sessionsName []byte maxAge time.Duration } const TimeStampFormat = "2006-01-02 15:04:05.000" /* NewBoltSt...
package bootstrap import ( "database/sql" _ "github.com/mattn/go-sqlite3" "github.com/superbet-group/code-cadets-2021/homework_4/02_bets_api/cmd/config" ) // RabbitMq bootstraps the rabbit mq connection. func Sqlite() *sql.DB { db, err := sql.Open("sqlite3", config.Cfg.SqliteDatabase) if err != nil { panic(err...
package main import ( "crypto/md5" "encoding/json" "errors" "os" "sort" ) func combine() error { inputMaps := make([]map[int]exercice, len(inputFiles)) for i, f := range inputFiles { m := map[int]exercice{} file, err := os.Open(f) if err != nil { return err } dec := json.NewDecoder(file) err = ...
package pgsql import ( "testing" ) func TestTime(t *testing.T) { testlist2{{ data: []testdata{ { input: timeval(21, 5, 33, 0), output: timeval(21, 5, 33, 0)}, { input: timeval(4, 5, 6, 789), output: timeval(4, 5, 6, 789)}, }, }, { scanner: TimeToString, data: []testdata{ { in...
// Copyright 2019 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
package game import ( "errors" "fmt" "github.com/smallgamefish/BreakBricks/protoc/github.com/smallgamefish/BreakBricks/protoc" "net" "sync" ) const ( MaxRoomNumber = 500 ) //房间管理者 var RoomManage *roomManage func init() { if RoomManage == nil { RoomManage = &roomManage{conn: nil, roomMap: make(map[string]*R...
package core const ( IndexType = iota + 1 UniqueType ) // database index type Index struct { Name string Type int Cols []string } // add columns which will be composite index func (index *Index) AddColumn(cols ...string) { for _, col := range cols { index.Cols = append(index.Cols, col) } } // new an index ...
package main import ( "database/sql" "errors" "fmt" _ "github.com/go-sql-driver/mysql" "github.com/jessevdk/go-flags" _ "github.com/lib/pq" _ "github.com/mattn/go-sqlite3" "github.com/alokmenghrajani/sqlc/sqlc" "log" "os" ) var VERSION string = "0.1.5" var opts sqlc.Options var parser = flags.NewParser(&op...
package testdata import ( "github.com/taktakty/netlabi/models" ) var HostOSTestData = []models.HostOS{ { Name: "test name 1", Note: "test note 1", }, { Name: "test name 2", Note: "test note 2", }, { Name: "test name 3", Note: "test note 3", }, { Name: "test name 4", Note: "test note 4", }, {...
package examples import ( "fmt" "github.com/corbym/gocrest/then" "testing" "github.com/corbym/gocrest/is" "github.com/cybernostics/cntest" ) func TestContainer(t *testing.T) { cnt := cntest.NewContainer().WithImage("hello-world:latest") name, err := cnt.Start() defer cnt.Remove() then.AssertThat(t, err, is....
/* Imagine a very simple language. It has just 2 syntax features: () indicates a block scope, and any word consisting only of 1 or more lower case ASCII letters, which indicates a identifier. There are no keywords. In this language, the value of identifiers is not important except when they appear multiple times. Thu...
// Copyright 2017 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
package transform import ( "bytes" "errors" "image" _ "image/draw" _ "image/gif" "image/jpeg" _ "image/png" ) var JpegQuality = 100 var ErrUnknownFormat = errors.New("can't decode: unknown image format") type Img struct { } func (Img) Encode(img image.Image) ([]byte, error) { buf := &bytes.Buffer{} err := ...
package destroy import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/openshift/installer/pkg/asset/cluster" "github.com/openshift/installer/pkg/destroy/providers" ) // New returns a Destroyer based on `metadata.json` in `rootDir`. func New(logger logrus.FieldLogger, rootDir string) (provider...
package models import "github.com/dancewing/revel/orm" type YysAccount struct { ID int `orm:"pk;auto"` Email, Name, Comment string Level int } type YysCards struct { ID int `orm:"pk;auto"` Card string Level string Quantity int Account *YysAccount `orm:"rel(fk);c...
/* 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 may not use this fi...
package main import ( "fmt" "io" "log" "os" "sync" ) type LogLevel int var logger = NewLogger(os.Args[0] + " ") type LogServerConf struct { Level string Prefix string Syslog int } const ( LogError LogLevel = iota LogInfo LogDebug ) type Log struct { level LogLevel prefix string syslog bool ...
/* * EVE Swagger Interface * * An OpenAPI for EVE Online * * OpenAPI spec version: 0.2.2 * * Generated by: https://github.com/swagger-api/swagger-codegen.git * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obta...
/* Copyright 2019 The Yingxi.company Authors. All rights reserved. Go Error */ package errno var ( OK = &Errno{Code: 0, Message: "OK"} InternalServerError = &Errno{Code: 10001, Message: "Internal server errno"} )
// Package viztransform is the parent package of all viztransform packages. // // These include geometry, transform, and parse along with all commands defined // in cmd. package viztransform
// Copyright 2022 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" "math/rand" "strings" "time" "github.com/bwmarrin/discordgo" "github.com/tahkapaa/test_stuff/riot_api/riotapi" ) // Bot is a discordBot type Bot struct { Discord *discordgo.Session Channels map[string]*Channel db DB } // Channel is a channel with followed players type Cha...
package main import ( "fmt" "math" ) // 输入:nums = [2,3,1,5,4] // 输出:10 // 解释:通过翻转子数组 [3,1,5] ,数组变成 [2,5,1,3,4] ,数组值为 10 。 func main() { fmt.Println(maxValueAfterReverse([]int{ 2, 3, 1, 5, 4, })) } func maxValueAfterReverse(nums []int) int { n := len(nums) a, b := nums[0], nums[n-1] premax1 := math.MinInt ...
package model import ( "time" "gopkg.in/go-playground/validator.v9" ) //Articleの構造体にIDとdbのカラムのidをメタ情報化し、sqlxがSQLの実行結果と構造体を紐づける type Article struct { ID int `db:"id"` Title string `db:"title" form:"title" validate:"required,max=50"` Body string `db:"body" form:"body" validate:"required"` C...
package pn532 type Device interface { // Low level communication methods WriteCommand(p []byte) ReadData(p []byte) ReadAck() bool Ready() bool WaitReady(int64) bool } func OpenDevice(ss, clk, miso, mosi uint8) (device Device, err error) { return openDeviceSPI(clk, miso, mosi, ss) }
package main import ( "flag" "fmt" "math/rand" "sync" "time" ) type product int type producer struct { id int product } type customer struct { id int product } func main() { producersNumber := flag.Int("p", 1, "number of producers") customersNumber := flag.Int("c", 1, "number of customers") bufferSize ...
package scene import ( "github.com/eriklupander/rt/internal/pkg/config" "github.com/eriklupander/rt/internal/pkg/mat" "github.com/eriklupander/rt/internal/pkg/obj" "io/ioutil" "math" ) func SimpleGopher() *Scene { camera := mat.NewCamera(config.Cfg.Width, config.Cfg.Height, math.Pi/3.5) camera.Transform = mat...
package main import ( "github.com/stretchr/testify/assert" "testing" ) func TestRoles_add_on_nil_roles_dont_throw_error(t *testing.T) { ass := assert.New(t) var roles Roles roles.add() ass.Nil(roles) roles.add("any") ass.Contains(roles, "any") } func TestRoles_add_nil_role(t *testing.T) { ass := assert.New...
package main import ( "fmt" "net/http" "strings" ) func handler(w http.ResponseWriter, r *http.Request) { var userAgent = r.Header.Get("User-Agent") if strings.Contains(userAgent, "github-camo") { http.Redirect(w, r, "https://img.youtube.com/vi/"+r.URL.Query().Get("v")+"/0.jpg", 301) } else { http.Redirect(...
package str import ( "crypto/md5" "encoding/hex" "io" ) func MD5(str string) string { hasher := md5.New() io.WriteString(hasher, str) return hex.EncodeToString(hasher.Sum(nil)) }
/* Copyright 2017 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, ...