text
stringlengths
11
4.05M
// Copyright 2018, Irfan Sharif. // // 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...
/** * @Author: fanpengfei * @Description: * @File: main_test1 * @Version: 1.0.0 * @Date: 2020/5/26 13:07 */ package main import ( "fmt" "github.com/ebayboy/math-engine/engine" ) func main() { s := "0/0 + 2" // call top level function r, err := engine.ParseAndExec(s) if err != nil { fmt.Println(err) ...
// Copyright 2020 The VectorSQL Authors. // // Code is licensed under Apache License, Version 2.0. package expressions import ( "base/docs" "datavalues" ) func LT(left interface{}, right interface{}) IExpression { exprs := expressionsFor(left, right) return &BinaryExpression{ name: "<", argumentNames: [][]st...
package openrtb_ext // ExtImpMobileFuse defines the contract for bidrequest.imp[i].ext.prebid.bidder.mobilefuse type ExtImpMobileFuse struct { PlacementId int `json:"placement_id"` PublisherId int `json:"pub_id"` TagidSrc string `json:"tagid_src"` }
package main import ( "encoding/json" "fmt" "io/ioutil" "os" "github.com/develersrl/lunches/pkg/tuttobene" ) const ( usage = ` ____ ______________ _____ _____ | | | | | | ||__]|___|\ ||___ | |__| | | |__||__]|___| \||___ A tool for parsing TuttoBene's menus Usage: tuttobene <xlsx file> <output format...
package helmdeployer import ( "io" "github.com/rancher/fleet/internal/manifest" fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1" "github.com/sirupsen/logrus" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/chartutil" kubefake "helm.sh/helm/v3/pkg/kube/fake" "helm.sh/helm/v3/pkg/storage" ...
package internal import ( "context" "fmt" ) // Interface to deliver messages. type Deliverable interface { // Commit the given message on the state machine. Commit(message Message) Response } // A struct that is able to deliver message from the protocol. // The messages will be committed on the peer state machin...
package main import "fmt" type error interface(){ Error() ; } func main1(){ fmt.Println("teasdadsadasd") }
package history import ( "context" "fmt" "gorm.io/gorm" "time" ) const ( ActionCreate Action = "create" ActionUpdate Action = "update" userOptionKey userOptionCtxKey = pluginName + ":user" sourceOptionKey sourceOptionCtxKey = pluginName + ":source" ) var ( _ History ...
package mapping import ( _ "strconv" "github.com/omniscale/imposm3/element" "github.com/omniscale/imposm3/geom" ) func init() { RegisterFieldTypes( FieldType{ Name: "mapping_key_value", GoType: "string", Func: getField_KeyValueName, MakeFunc: nil, }, ) } func getField_KeyValueName(va...
// This file is part of CycloneDX GoMod // // 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 agr...
package test import ( "fmt" "io/ioutil" "log" "net/http" "net/http/httptest" "os" "strings" "testing" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" "github.com/Blackoutta/blog-service/global" v1 "github.com/Blackoutta/blog-service/internal/api/v1" "github.com/Blackoutta/blog-service/inte...
package leetcode_go import ( "sort" ) func subsetsWithDup(nums []int) [][]int { sort.Ints(nums) res := [][]int{} helperP90(nums, []int{}, 0, &res) return res } func helperP90(nums []int, curSet []int, pos int, res *[][]int) { *res = append(*res, curSet) for i := pos; i < len(nums); i++ { curSet = append(app...
package main import "fmt" func main() { foo() bar("James") s1 := woo("Moneypenny") fmt.Println(s1) x, y := mouse("Ian", "Fleming") fmt.Println(x) fmt.Println(y) } func foo() { fmt.Println("hello from foo") } // Everything in go is PASS BY VALUE func bar(s string) { fmt.Println("hello,", s) } //RETURN fu...
package controller import ( "github.com/Brickchain/go-document.v2" keys "github.com/Brickchain/go-keys.v1" jose "gopkg.in/square/go-jose.v1" ) // Binding describes the methods for managing a specific binding with it's related configuration. type Binding interface { // ID returns the ID of the binding. ID() stri...
// +build linux package systeminfo import ( "fmt" "io/ioutil" "strings" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs/system" ) type SysInfoStats struct { ps system.PS } func (_ *SysInfoStats) Description() string { return "R...
package handlers import ( "context" "github.com/PabloGilvan/transaction/cmd/helpers" "github.com/PabloGilvan/transaction/internal/services/account" "github.com/PabloGilvan/transaction/internal/services/transaction" "github.com/gin-gonic/gin" "net/http" ) type TransactionController struct { TransactionService t...
package main import ( "fmt" "net/http" "time" storage "github.com/alokyadav/buildings/storage" service "github.com/alokyadav/buildings/service" "github.com/gorilla/mux" "github.com/google/jsonapi" ) const ( headerAccept = "Accept" headerContentType = "Content-Type" ) func main() { jsonapi.Instrument...
package xin import ( "bufio" "io" "math" "math/rand" "os" "strings" "time" ) type formEvaler func(*Frame, []Value, *astNode) (Value, InterpreterError) type NativeFormValue struct { name string evaler formEvaler } func (v NativeFormValue) String() string { return "(<native form> " + v.name + ")" } func ...
// 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" "chromiumos/tast/common/storage" "chromiumos/tast/testing" ) func init() { testing.AddTest(&testing.Test{ Func: StorageWearoutDet...
package gopigtranslator import ( "strings" "unicode" ) func translateWord(word string) string { vowels := map[rune]bool{ 'a': true, 'e': true, 'i': true, 'o': true, 'u': true} prefix := make([]rune, len(word)) suffix := make([]rune, len(word)) postfix := "ay" if vowels[rune(word[0])] { postfix = "...
// Package messages wraps an i18n library. // Provides the needed to get translated messages. package messages
package splunk type Generator struct { Build string `json:"build"` Version string `json:"version"` } type Paging struct { Total int64 `json:"total"` PerPage int64 `json:"perPage"` Offset int64 `json:"offset"` } type UpdateSearchConcurrencySettingsScheduleReq struct { // MaxSearchesPer The maximum number o...
package main import ( "bytes" "crypto/sha256" "encoding/json" "flag" "fmt" "io" "io/fs" "log" "os" "os/exec" "os/user" "path/filepath" "strconv" "strings" "time" ) type Config struct { User, Group string Prefix string ExecPrefix string Bindir string Libexecdir string Localst...
package utils import "testing" func TestAdd(t *testing.T) { expected := 10 actual := Add(1,2,3,4) if actual != expected { t.Errorf("no iguales se espera %d pero se obtiene %d", expected, actual) } }
package rooms import ( "log" "strings" "github.com/Iteam1337/go-udp-wejay/room" "github.com/Iteam1337/go-udp-wejay/users" ) type Rooms struct { rooms map[string]*room.Room } func (r *Rooms) Get(id string) (room *room.Room) { if res, ok := r.rooms[id]; ok { room = res } return } func (r *Rooms) Restore()...
package server import ( "IMServer/internal/server/conf" "IMServer/internal/server/model" "fmt" "io" "net" "reflect" "time" "go.uber.org/zap" "gogit.oa.com/March/gopkg/metric" "gogit.oa.com/March/gopkg/util" "gogit.oa.com/March/gopkg/protocol/bypack" ) type TCPPackage struct { conn net.Conn reader *...
package main import ( // Standard library packages "fmt" "log" "net" "net/http" "strconv" // Third party packages "github.com/julienschmidt/httprouter" "github.com/skratchdot/open-golang/open" ) // https://blog.golang.org/context/userip/userip.go func getIP(w http.ResponseWriter, req *http.Request, _ httpro...
package models // Copyright 2016-2017 MediaMath // // 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" "github.com/tallongsun/testmod/hi" ) func main() { fmt.Println(hi.Hi("x")) }
package main import ( "fmt" "math/rand" "time" ) func random(min, max int) int { return rand.Intn(max-min) + min } func main() { rand.Seed(time.Now().UnixNano()) for i := 0; i < 10; i++ { randomNum := random(1, 6) fmt.Printf("Play %d - Random number : %d\n", i, randomNum) } }
package main import ( "IMServer/internal/server" "IMServer/internal/server/conf" "flag" "fmt" "math/rand" "os" "os/signal" "syscall" "time" "go.uber.org/zap" ) var ( BuildTime = "unset" Commit = "unset" Release = "unset" ) var ( ConfFile string Version string ) func init() { rand.Seed(time.No...
package id_035 func twoSum(nums []int, target int) []int { var a []int = make([]int, 2) for i := 0; i < len(nums) - 1; i++ { for j := i + 1; j < len(nums); j++ { if nums[i] + nums[j] == target { a[0] = i a[1] = j } } } return a }
package main //basic mutex - locks for both reading and writing //RWmutex - more flexible allows for reading, but locks for writing import ( "fmt" "runtime" "sync" ) func main() { fmt.Println("CPUs:", runtime.NumCPU()) fmt.Println("GO routines:", runtime.NumGoroutine()) counter := 0 const gs = 100 var wg syn...
package helpers import ( "bytes" "fmt" "strings" "unicode" ) func isAlphabetical(c rune) bool { return isLower(c) || isUpper(c) } func isUpper(c rune) bool { return 'A' <= c && 'Z' >= c } func isLower(c rune) bool { return 'a' <= c && 'z' >= c } func isNumeric(c rune) bool { return '0' <= c && '9' >= c } ...
package controllers import ( "github.com/astaxie/beego" "intra-hub/db" "intra-hub/models" ) type CalendarController struct { BaseController } func (c *CalendarController) Add() { c.RequireManager() c.EnableRender = false calendar := &models.Calendar{} if err := c.ParseForm(calendar); err != nil { beego.Err...
package main import ( "fmt" "io/ioutil" "net/http" "time" "github.com/pkg/errors" "github.com/tidwall/gjson" "github.com/dailymotion/code-review-for-interviews/model" ) func loadCurrencies(currencyCodes []string) ([]model.Currency, error) { currencies := make([]model.Currency, len(currencyCodes)) for i, cu...
package model type Param struct { SchoolId int64 `form:"schoolId" binding:"required"` ExamId int64 `form:"examId" binding:"required"` }
package controllers import ( "fmt" "net/http" ) func ByeController(w http.ResponseWriter, req *http.Request) { fmt.Fprintf(w, "Bye!") }
// 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 cloudformation // AWSGlueClassifier_JsonClassifier AWS CloudFormation Resource (AWS::Glue::Classifier.JsonClassifier) // See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-classifier-jsonclassifier.html type AWSGlueClassifier_JsonClassifier struct { // JsonPath AWS CloudFo...
package main import ( "network" "quorum" "testing" ) func TestNetworkedQuorum(t *testing.T) { // create a tcp server and 2 states // ms == messageSender ms, err := network.NewTCPServer(9980) if err != nil { println("fail") } // mh == messageHandler _, err = quorum.CreateState(ms) if err != nil { printl...
package main import ( "bufio" "fmt" "log" "os" "strings" ) func details(s string) int { t := strings.Split(s, ",") m := len(t[0]) for _, i := range t { if n := strings.Index(i, "Y") - strings.LastIndex(i, "X"); n < m { m = n } } return m - 1 } func main() { data, err := os.Open(os.Args[1]) if err ...
package main import ( "html/template" "os" "fmt" ) type Person struct { Name string Age int Emails []string Jobs []*Job //指针的引用, 引用到 job 的结构体去 } type Job struct { Employer string Role string } const templ = `The name is {{.Name}}. The age is {{.Age}}. {{range .Emails}} ...
/* * Lean tool - hypothesis testing application * * https://github.com/MikaelLazarev/willie/ * Copyright (c) 2020. Mikhail Lazarev * */ package marketing import ( "context" "github.com/MikaelLazarev/willie/server/core" ) type service struct { store core.MarketingStoreI cache map[string][]byte isCache...
package spotify_client import ( "context" c "github.com/davidiola/ucc_twitter_bot/constants" u "github.com/davidiola/ucc_twitter_bot/utils" "github.com/zmb3/spotify" "golang.org/x/oauth2/clientcredentials" "log" ) type SpotifyCl struct { c *spotify.Client } func NewSpotifyCl() *SpotifyCl { config := &clientc...
package openrtb_ext type ExtImpBetween struct { Host string `json:"host"` PublisherID string `json:"publisher_id"` }
package mocks import ( "errors" "github.com/joaodias/hugito-app/usecases" "golang.org/x/oauth2" ) type RepositoryInteractor struct { IsNewError bool IsValidateError bool IsNewCalled bool IsValidateCalled bool IsValidRepository bool } func (ri *RepositoryInteractor) New(name, projectBranch, pu...
package charts import ( "fmt" "time" "github.com/imdario/mergo" "github.com/linkerd/linkerd2/pkg/k8s" "k8s.io/helm/pkg/chartutil" "sigs.k8s.io/yaml" ) const ( helmDefaultChartDir = "linkerd2" helmDefaultHAValuesFile = "values-ha.yaml" ) type ( // Values contains the top-level elements in the Helm chart...
package presenters import ( "encoding/json" "io" "github.com/pivotal-cf/om/api" "github.com/pivotal-cf/om/models" ) type JSONPresenter struct { stdout io.Writer } func NewJSONPresenter(stdout io.Writer) JSONPresenter { return JSONPresenter{ stdout: stdout, } } func (j JSONPresenter) PresentAvailableProduc...
package main import ( "github.com/TutorialEdge/api.tutorialedge.net/database" "github.com/TutorialEdge/api.tutorialedge.net/users" "github.com/aws/aws-lambda-go/events" "github.com/aws/aws-lambda-go/lambda" ) func handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { db, err :...
package helper import "errors" func Compact(list []interface{}) ([]interface{}, error) { if list == nil { return nil, errors.New("missing list") } results := []interface{}{} for _, v := range list { if v != 0 && v != false && v != "" { results = append(results, v) } } return results, nil }
// ===================================== // // 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 main import ( "bytes" "fmt" "html/template" "io" "io/ioutil" "log" "net/http" "os" "path/filepath" "strconv" "strings" "time" "github.com/karrick/godirwalk" "gopkg.in/urfave/cli.v1" ) var ( dir http.Dir er error programName string tmplt *templa...
package recommend import ( "fmt" "log" "time" "regexp" "net/url" "sort" "github.com/syou6162/go-active-learning-web/lib/submodular" "github.com/syou6162/go-active-learning/lib/classifier" "github.com/syou6162/go-active-learning/lib/hatena_bookmark" "github.com/syou6162/go-active-learning/lib/model" "git...
package main import "fmt" func main() { numeros := make([]int, 0, 6) fmt.Println(numeros[0:6]) }
package main import ( "fmt" "time" ) /* 结构体是一种聚合的数据类型,是由零个或者多个任意类型的值聚合而成的实体。 每一项值都称为结构体的成员, 结构体变量的成员可以通过 点操作符 访问,如 a.ID, 结构体是变量,他的成员也是变量。 操作结构体的成员变量: 1. 直接操作 2. 对成员取地址,然后通过指针访问 通常一行对应一个结构体的成员,名字在前,类型在后,如果相邻的成员类型相同可以合并到一行, 成员的顺序有意义,成员也依赖于大写开头即可以导出的规则。 命名为 S 的结构体不能有 S 类型的成员,但是 S 类型结构体可以包含 *S 指针类型的成员。 ...
package udp import "fmt" type UnknownDirective struct { Key_name string unknonw_dir string } func (ukd UnknownDirective) Error() string { return fmt.Sprintf("error: %s does not have directive named %s\n", ukd.Key_name, ukd.unknonw_dir) } type DuplicatedUdp struct { Key_name string udp_name string } func (dudp...
package main import ( "context" "encoding/json" "errors" "flag" "log" "time" "github.com/trains629/ms/base" ) var ( _timeout = flag.Int64("ttl", int64(2*time.Second), "timeout") _Endpoints = base.StringArray{} _serviceName = flag.String("service", "", "service name") _port = flag.Int64("port"...
package worker import ( "fmt" "io" "strings" ) const ( travisFoldStart = "travis_fold:start:%s\r\033[0K" travisFoldEnd = "travis_fold:end:%s\r\033[0K" ) func writeFold(w io.Writer, name string, b []byte) (int, error) { folded := []byte(fmt.Sprintf(travisFoldStart, name)) folded = append(folded, b...) if s...
package server import ( "log" "sync" // "github.com/et-zone/gcelery/control" pb "github.com/et-zone/gcelery/protos/base" "github.com/et-zone/gcelery/task" "google.golang.org/grpc" "google.golang.org/grpc/credentials" ) var client *CeleryClient var err error const TimeOut = 60 type CeleryClient struct { con...
package util import "testing" func TestGetCurrentDate(t *testing.T) { date := GetCurrentDate() if date == "" { t.Errorf("couldn't get the current date err: %v\n", date) } }
package main import ( "github.com/rs/zerolog" "github.com/cloudflare/cloudflared/config" "github.com/cloudflare/cloudflared/overwatch" ) // AppService is the main service that runs when no command lines flags are passed to cloudflared // it manages all the running services such as tunnels, forwarders, DNS resolve...
package main import ( "context" "errors" "fmt" "github.com/go-graphite/carbonapi/expr" pb "github.com/go-graphite/carbonzipper/carbonzipperpb3" realZipper "github.com/go-graphite/carbonzipper/zipper" "go.uber.org/zap" ) var errNoMetrics = errors.New("no metrics") type zipper struct { z *realZipper.Zipper ...
package handler import ( "net/http" "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" "github.com/solntsevatv/url_translater/internal/url_translater" ) func (h *Handler) longToShort(c *gin.Context) { var input url_translater.LongURL if err := c.BindJSON(&input); err != nil { newErrorResponse(c, http.S...
package graph // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. import ( "BackEnd/graph/generated" "BackEnd/middleware" "BackEnd/models" "context" "errors" "time" ) func (r *m...
/******************************************************************************* * Copyright 2017 Samsung Electronics 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...
// 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 main import ( "encoding/json" "fmt" "log" "os" pb "github.com/inigofu/temac-user-service/proto/auth" microclient "github.com/micro/go-micro/client" "github.com/micro/go-micro/cmd" "github.com/micro/go-micro/metadata" "golang.org/x/net/context" ) func main() { cmd.Init() // Create new greeter cli...
package linklist import ( "fmt" "DA/2_linklist/linknode" ) // LList ... type LList struct { Head *linknode.LNode Tail *linknode.LNode Length int PrtHead bool Duplicate bool } // Output ... func (ll *LList) Output() { if ll.Head == nil { return; } prtLen := ll.Length if ll.PrtHead { prtLen = ll.Lengt...
package leetcode /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func postorderTraversal(root *TreeNode) []int { result := []int{} postOrder(root, &result) return result } func postOrder(root *TreeNode, result *[]int) { if ro...
// Tomato static website generator // Copyright Quentin Ribac, 2018 // Free software license can be found in the LICENSE file. package main import ( "fmt" ) // Siteinfo contains the site-wide meta. There should be only one of them. // Title and Subtitle will be printed in the header, // Description will be printed ...
package main import ( "fmt" "log" "github.com/bambocher/opencorpora" ) func main() { dict, err := opencorpora.NewDictionary("../../dict.opcorpora.xml") if err != nil { log.Panicln(err) } for _, lemma := range dict.Lemmata { fmt.Println(lemma.Default.Name) } }
package middleware import ( "github.com/gin-gonic/gin" "github.com/jinzhu/gorm" "github.com/streadway/amqp" ) func SetDBtoContext(db *gorm.DB) gin.HandlerFunc { return func(c *gin.Context) { c.Set("DB", db) c.Next() } } func SetRabbitMQContext(conn *amqp.Connection) gin.HandlerFunc { return func(c *gin.Con...
// Copyright 2017 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 types import ( "fmt" "reflect" "strconv" ) var ( // ErrNotSliceOrArray is returned when the value is not a slice. ErrNotSliceOrArray = fmt.Errorf("the value is not a slice or array") // ErrNotMap is returned when the value is not a map. ErrNotMap = fmt.Errorf("the value is not a map") // ErrNotStrin...
package nanovgo import ( "image" "image/color" "image/draw" "log" "github.com/shibukawa/nanovgo/fontstashmini" ) type Context struct { gl *glContext commands []float32 commandX float32 commandY float32 states []nvgState cache nvgPathCache tessTol floa...
/* Copyright 2019 NetApp. 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 distrib...
/* @File : grpcServer.go @Time : 2022/02/08 10:13:28 @Author : lpp @Version : 1.0.0 @Contact : golpp@qq.com @Desc : grpc服务 */ package grpcServer import ( "context" "net" "grpc-rest/protos" "google.golang.org/grpc" ) // type OrderServiceImpl struct { } func (OrderServiceImpl) Create(conte...
package main import ( "bytes" "flag" "fmt" "github.com/bwmarrin/discordgo" "github.com/spf13/viper" "goed/cyborg" "io" "io/ioutil" "log" "net/http" _ "net/http/pprof" "os" "os/signal" "syscall" ) type CyborgBotConfig struct { DiscordConf cyborg.CyborgBotDiscordConfig GalaxyInfoCenter struct { Addres...
package alphabet_soup import ( "fmt" "testing" ) func Test_AlphabetSoup(t *testing.T) { fmt.Println(AlphabetSoup("hello")) fmt.Println(AlphabetSoup("world")) fmt.Println(AlphabetSoup("coderbyte")) fmt.Println(AlphabetSoup("hooplah")) }
package monito import ( "fmt" "io" "time" "github.com/PI-Victor/monito/pkg" "github.com/PI-Victor/monito/pkg/log" ) // Server - Main monitoring service core struct type Server struct { configDir string ConfigFile string output io.Writer MainNode bool } func New(confFile string) *Server { return &Se...
// method forwading in the form of struct embedding - specify a type without field name // embed structure in line 9,10 package main import "fmt" type report struct { sol int temperature location } type temperature struct { high, low celsius } type location struct { lat, long float64 } type celsius float64 fun...
package runtime_test import ( . "github.com/d11wtq/bijou/runtime" "testing" ) func TestStringType(t *testing.T) { s := String("example") if s.Type() != StringType { t.Fatalf(`expected s.Type() == StringType, got %s`, s.Type()) } } func TestStringEvalToSelf(t *testing.T) { s := String("example") env := FakeE...
package main import ( "encoding/json" "github.com/go-redis/redis" "github.com/gorilla/mux" "github.com/satori/go.uuid" "log" "net/http" "strings" ) type Person struct { ID string `json:"id,omitempty"` Firstname string `json:"firstname,omitempty"` Lastname string `json:"lastname,omitempty"` Social []SocialM...
package utils import ( cryptorand "crypto/rand" "encoding/hex" "fmt" ) func NewNamespaceName() (string, error) { p := make([]byte, 12) _, err := cryptorand.Read(p) if err != nil { return "", err } return fmt.Sprintf("test-%s", hex.EncodeToString(p))[:12], nil }
package cmd import "strings" // validateString compares the two strings. func validateString(expected string, actual string) bool { if strings.Compare(expected, actual) != 0 { return false } return true }
// 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 p2p contains the common code for P2P tests. // // The most challenging part of P2P tests is that the P2P protocol uses // multicasts for DNS-SD, but multicasts do ...
// 138. Writer interface 各種 寫與印 的方法(func) // Encorder 144. main 和 看圖 // 扯到file 都會友 Write的type //https://golang.org/pkg/os/#NewFile // func WriteFile ¶ https://golang.org/pkg/io/ioutil/#WriteFile // func (*File) Write ¶ https://golang.org/pkg/os/#File.Write package main import ( "fmt" "io" "os" ) func main() { ...
package wyre import ( "fmt" ) type APIError struct { Language string `json:"language"` ExceptionID string `json:"exceptionId"` CompositeType string `json:"compositeType"` SubType APIErrorSubType `json:"subType"` Message string `json:"message"` Type ...
/* 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 daemon import ( "io" "os/exec" ) // Service is a process wrapper for 3rd party binaries. It will spawn an instance // of the binary and manage the life-cycle and IO of the process. type Service interface { Setup() Stop(pid int) (bool, error) List() map[int]*exec.Cmd Command() *exec.Cmd Start() *exec.Cm...
package controllers import ( "encoding/json" "fmt" "net/http" "unit-tested-controllers.com/externals" ) func CallApiPlaceholder(apiClient externals.IApiClient) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { posts, err := apiClient.GetPosts() if err != nil { fmt.Fprint(w, "Oops...
package model import ( "encoding/json" "github.com/caos/zitadel/internal/errors" "github.com/caos/zitadel/internal/eventstore/models" es_models "github.com/caos/zitadel/internal/eventstore/models" org_model "github.com/caos/zitadel/internal/org/model" ) type OrgIamPolicy struct { models.ObjectRoot Description...
package main import ( "context" "crypto/sha256" "encoding/json" "errors" "fmt" "io/ioutil" "net/http" "os" "strconv" "strings" "time" "github.com/olivere/elastic/v7" "github.com/pimmytrousers/pastescraper/parse" "github.com/pimmytrousers/pastescraper/parse/individualparsers" log "github.com/sirupsen/lo...
package mvc import ( "github.com/rcrowley/go-metrics" "github.com/zerolinke/pudge/src/pudge/proto" ) //UpdateStatus 更新状态 type UpdateStatus int const ( //TODO 枚举 UpdateNone = -1 * iota //更新无:-0 UpdateInstalling //更新安装中:-1 UpdateReady //更新准备:-2 UpdateAvailable //更新活动:-3...
package yaraparser_test import ( "reflect" "strings" "testing" "github.com/nbareil/yaraparser-go" ) func TestParser_Test(t *testing.T) { var tests = []struct { s string rule *yaraparser.YaraRule err string }{ // Single field statement { s: `rule foobar {}`, rule: &yaraparser.YaraRule{ N...
// 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 arc import ( "context" "time" "chromiumos/tast/local/arc" "chromiumos/tast/local/arc/optin" "chromiumos/tast/local/chrome" "chromiumos/tast/local/chrome/famil...
package application import ( "encoding/json" "fmt" "github.com/brooklyncentral/brooklyn-cli/models" "github.com/brooklyncentral/brooklyn-cli/net" ) //WIP func Fetch(network *net.Network) (string, error) { url := "/v1/applications/fetch" body, err := network.SendGetRequest(url) if err != nil { return "", err ...
package main import ( "crypto/hmac" "crypto/sha256" "fmt" "html/template" "log" "net/http" "regexp" "sort" "strings" ) const POW_BITS = 12 const POW_FIELD = "__pow__" var indexTemplate *template.Template var enrollTemplate *template.Template var flagTemplate *template.Template var cookieName = "1337_AUTH" ...