text
stringlengths
11
4.05M
package rpc_service import "ms/sun/shared/x" type rpc_other int func (rpc_other) Echo(param *x.PB_OtherParam_Echo, userParam x.RPC_UserParam) (res x.PB_OtherResponse_Echo, err error) { res.Text = " +++ " + param.Text + " Hamid ++++" return }
// programa que calcula os primeiros N números da sequência de fibonacci // neste exemplo cada número será calculado por uma goroutine diferente // se tivermos um número alto de cores no nosso processador, poderemos criar mais goroutines, melhorando a performance do programa package main import ( "fmt" ) ...
package mqtt type Handler interface { Connect(ctx *Context, username, password string) error Disconnect(ctx *Context) Publish(ctx *Context, msg *Message) error Subscribe(ctx *Context, topic string, qos byte) error }
package dialog import ( "regexp" "strings" "sync" "gopkg.in/telegram-bot-api.v4" ) //Processor calculates users traverses by the dialog tree type Processor interface { GetNodeToMoveIn(msg *tgbotapi.Message, bot *tgbotapi.BotAPI) *TreeNode RunNodeHandler(node *TreeNode, msg *tgbotapi.Message, bot *tgbotapi.Bot...
package manager type Manager interface{ Init() Process() }
package natss import ( "errors" "fmt" "github.com/nats-io/nats.go" pubsub "github.com/utilitywarehouse/go-pubsub" ) // ErrNotConnected is returned if a status is requested before the connection has been initialized var ErrNotConnected = errors.New("nats not connected") func natsStatus(nc *nats.Conn) (*pubsub.St...
package drivestream import ( "fmt" "io" "time" ) // newTaskLogger returns a task logger that will write to w. func newTaskLogger(w io.Writer) taskLogger { return taskLogger{out: w} } // A taskLogger writes logs for a task. type taskLogger struct { out io.Writer task string start time.Time } // Task return...
package CronJob import( "Travel/DataParsing" "fmt" // This package is used for running cron Jobs "github.com/jasonlvhit/gocron" ) func task() { fmt.Println("Task is being performed.") DataParsing.InputData() } func DoCronJob(t uint64){ /* There one loop will be added which will execute task a...
// Wrapper around os.File that encrypts/decrypts all data read/written to it // // Function Open() conforms to the os.OpenFile() interface, taking filename // `fname`, flags `fs` and permissions `p` as well as special `key` parameter // which is used to construct steam cipher. Implementation expects 256-bit keys // for...
package main import ( "fmt" "go/ast" "go/importer" "go/parser" "go/token" "go/types" "io" "os" "path/filepath" "strings" ) func ExportDirConst(w io.Writer, path string) error { filter := func(finf os.FileInfo) bool { return !strings.HasSuffix(finf.Name(), "_test.go") } fset := token....
package deplog type Debugger interface { Debug(message string) } type ArgsDebugger interface { Debug(args ...interface{}) } type FormatDebugger interface { Debugf(format string, args ...interface{}) } type Infoer interface { Info(message string) } type ArgsInfoer interface { Info(args ...interface{}) } type ...
package logger import ( "runtime" "time" "go.uber.org/zap/buffer" "go.uber.org/zap/zapcore" ) type stdoutEncoder struct { *zapcore.EncoderConfig internal zapcore.Encoder } func (enc stdoutEncoder) AddArray(key string, arr zapcore.ArrayMarshaler) error { return enc.internal.AddArray(key, arr) } func (enc std...
package device import( "io/ioutil" "strings" "log" ) func FindDevices() []string { var devices []string contents, _ := ioutil.ReadDir("/dev") // Look for what is mostly likely the Arduino device var port string for _, f := range contents { if strings.Contains(f.Name(), "tty.usbserial") || strings.C...
package ewallet import ( goxendit "github.com/xendit/xendit-go" "github.com/xendit/xendit-go/ewallet" "github.com/imrenagi/go-payment/invoice" ) // Deprecated: newBuilder generate legacy ewallet body request for xendit. This API is // deprecated. Consider to use the newEWalletChargeRequestBuilder func newBuild...
package main import ( "fmt" "github.com/spf13/cobra" "github.com/spf13/viper" "github.com/takeru56/cnos/cinii" "log" "net/url" "os" "strconv" ) type articlesFlags struct { keyword string title string author string yearfrom int yearto int count int sort int lang int fulltext bool }...
package main import ( "bytes" "encoding/binary" "fmt" "io" "io/ioutil" mathrand "math/rand" "os" "path/filepath" "time" "crypto" "crypto/rand" "crypto/rsa" "crypto/sha256" "crypto/x509" "encoding/pem" ) const ( EL_TAG_SIZE = 8 + 8 + 16 MAX_GROUP_SIZE = 1000 LSAGS_PK_SIZE = 29 ) var server_sk *...
package notification // Notification es una interfaz que deben implementar los notificadores // Para un ejemplo ir a notification.Email type Notification interface { ID() string Notify(data []byte) error }
package fs import ( "os" "path/filepath" "strconv" "strings" ) // CoverDirName const const CoverDirName = "cover" // PodcastsDirName const const PodcastsDirName = "podcasts" // FrontDirName const const FrontDirName = "front" // Error type type Error struct { Err error } func (err *Error) Error() string { re...
package main import "fmt" func main() { a := 42 fmt.Printf("%d\n", a) fmt.Printf("%b\n", a) fmt.Printf("%#x\n", a) b := a << 1 fmt.Printf("%d\n%b\n%#x\n", b, b, b) }
package mail_test import ( "bytes" "log" "os" "strings" "time" "github.com/cloudfoundry-incubator/notifications/mail" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Mail", func() { var mailServer *SMTPServer var client *mail.Client var logger *l...
package utils import ( "errors" "fmt" "io" "io/ioutil" "mime" "net/http" "net/url" "os" "path/filepath" "regexp" "runtime" "strings" "time" "github.com/alex-phillips/lychee/lib/log" ) var DryRun bool = false func Chunk(items []string) (retval [][]string) { numCPUs := runtime.NumCPU() chunkSize := (l...
package problem0344 import ( "testing" "github.com/stretchr/testify/assert" ) func TestReverseString(t *testing.T) { bytes := []byte("abcdefg") reverseString(bytes) assert.Equal(t, "gfedcba", bytes) }
package main import ( "testing" "github.com/stretchr/testify/assert" ) func Test_main(t *testing.T) { if !assert.Truef(t, isValidBST(nil), "nil") { t.FailNow() } r := &TreeNode{ Val: 1, Left: nil, Right: nil, } if !assert.Truef(t, isValidBST(r), "one") { t.FailNow() } r = &TreeNode{ Val: ...
/* * @lc app=leetcode.cn id=10 lang=golang * * [10] 正则表达式匹配 */ // @lc code=start package main import "fmt" func main() { var s, p string s = "aa" p = "a" fmt.Printf("%s, %s, %t\n", s, p, isMatch(s, p)) s = "aa" p = "a*" fmt.Printf("%s, %s, %t\n", s, p, isMatch(s, p)) s = "ab" p = ".*" fmt.Printf("%s...
package acceptance import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "github.com/cloudfoundry-incubator/notifications/acceptance/servers" "github.com/cloudfoundry-incubator/notifications/config" "github.com/cloudfoundry-incubator/notifications/models" "github.com/pivota...
/* * Copyright 2018, CS Systemes d'Information, http://www.c-s.fr * * 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 requir...
// Copyright 2017 The Fuchsia 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 index implements a basic index of packages and their relative // installation states, as well as thier various top level metadata properties. pa...
package config import ( "fmt" "net/url" "strings" "github.com/spf13/pflag" ) type Route struct { from *url.URL to *url.URL } func (r *Route) To() *url.URL { return r.to } func (r *Route) From() *url.URL { return r.from } func (r *Route) String() string { if r == nil { return "" } return fmt.Sprint...
package main import "fmt" // When a function encounters a panic, // its execution is stopped, any deferred functions are executed and then the control returns to its caller. func fullName(firstName *string, lastName *string) { defer fmt.Println("deferred call in fullName") if firstName == nil { panic...
package endpoints const ( // ParamSpotName is the path parameter key for spotName ParamSpotName = "spotName" )
package auth import ( "encoding/json" "errors" "github.com/boltdb/bolt" "github.com/ubclaunchpad/inertia/daemon/inertiad/crypto" ) var ( errSessionNotFound = errors.New("Session not found") errCookieNotFound = errors.New("Cookie not found") errUserNotFound = errors.New("User not found") ) const ( loginA...
// use {{ .Method }}. package main import ( "bytes" "flag" "fmt" "io" "os" "strings" "text/template" ) const tmplText = `Usage: {{ .Name }} [Options] Description: Short description Options: {{ .SDefaults }} Examples: {{ .SExamples }} ` type Mycmd struct { name string fs *flag.FlagSet w io.Writer...
package twitchchat const ( host = "irc.chat.twitch.tv" ) type ( Configuration struct { Host string Nickname string Oauth string Channel string } ) func NewConfiguration(nickname, oauth, channel string) (configuration *Configuration) { configuration = &Configuration{ Host: host, Nickname: ...
package main import ( "math" ) type Sine struct { Effect Position float64 Frequency float64 // defines how many waves are displayed per edge offset float64 // moves the waves along the edge delta float64 // step size the offset increases per loop loopTime float64 // [s] time the waves need to move one...
//go:build go1.18 package parquet_test import ( "bytes" "encoding/binary" "errors" "fmt" "io" "math/rand" "reflect" "sort" "testing" "github.com/segmentio/parquet-go" "github.com/segmentio/parquet-go/encoding" ) func TestRowBuffer(t *testing.T) { testRowBuffer[booleanColumn](t) testRowBuffer[int32Colum...
package main import ( "fmt" "time" ) type Conn struct { id int ns time.Duration } func (conn Conn) String() string { return fmt.Sprintf("Conn {id: %v, ms=%v}", conn.id, conn.ns) } func (conn *Conn) DoQuery() string { time.Sleep(conn.ns) return conn.String() } func Query(conns []Conn) string { ch := make...
package web_handler /* * this is the FrontInterface which could be implemented by developer * developer can designed new struct and new struct can implement those two method */ type FrontInterface interface { BindMethod() string BindPath() string } func (front *FrontInterface) BindMethod() { return "GET" }
package 博弈问题 func canWinNim(n int) bool { isVisit = make(map[int]bool) return canWinNimExec(n, 3, true) } var isVisit map[int]bool // 记忆化搜索 func hash(n int, turn bool) int { turnNumber := 0 if turn == true { turnNumber = 1 } return (n << 2) | turnNumber } func canWinNimExec(n int, maxPick int, turn bool) boo...
package main import ( "bufio" "errors" "fmt" "os" ) var ( message string cipher string key int ) type Msg struct { Flag int // 选择功能 Data string Key int } func main() { msg, err := typeIn() for err != nil { fmt.Println(err, "\n--------------------") msg, err = typeIn() ...
package chapter31 import ( "net/http" "fmt" "encoding/json" ) func init() { fmt.Println("=== JSON Publisher ===") http.HandleFunc("/", serveRest) http.ListenAndServe("localhost:8181", nil) } func serveRest(w http.ResponseWriter, r *http.Request){ response, err := publishJson() if err != nil { panic(err) }...
package ctrl import ( "fmt" ) type TestController struct { Name string } func (ctrl *TestController) Index() { fmt.Print("TestController.index") }
// Copyright 2016 henrylee2cn. All rights reserved. // Use of this source code is governed by a MIT style // license that can be found in the LICENSE file. package core import ( "github.com/henrylee2cn/thinkgo/core/config" "log" ) type Config struct { AppName string // 应用名称 RunMode string // 运行模式 "release"/"...
package api import ( "context" "github.com/gremlinsapps/avocado_server/api/model" "github.com/gremlinsapps/avocado_server/dal/model" "github.com/gremlinsapps/avocado_server/dal/sql" ) func (r *mutationResolver) CreateResource(ctx context.Context, input apimodel.NewResource) (*apimodel.Resource, error) { repo, er...
package flagen import ( "strconv" "testing" ) func TestToValue(t *testing.T) { tests := map[string]string{ "1": "int", "1.0": "float", "true": "bool", "abc": "string", } for test, expect := range tests { value := toValue(test) if typ := value.Type(); typ != expect { t.Errorf("toValue should r...
package main import ( "time" "fmt" ) func main() { // Simple integer channel channel := make(chan int) go func() { for i := 0; i < 10; i++ { channel <- i time.Sleep(time.Second) } }() go func() { for { value := <- channel ...
package AUSTC_website import( "net/http" "os" "encoding/json" ) type Data struct { Name string Email string Dept string Occupation string message string } func save(w http.ResponseWriter, r *http.Request) { name := r.FormValue("first_name") email := r.FormValue("email") dept := r.FormValue("dept") occup ...
package waves import ( "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/viper" "github.com/foundriesio/fioctl/client" "github.com/foundriesio/fioctl/subcommands" ) func init() { cmd.AddCommand(&cobra.Command{ Use: "rollout <wave> <group>", Short: "Rollout a given wave to devices in...
package config import ( "xd/lib/configparser" ) type LogConfig struct { Level string } func (cfg *LogConfig) Load(s *configparser.Section) error { cfg.Level = "info" if s != nil { cfg.Level = s.Get("level", "info") } return nil } func (cfg *LogConfig) Save(s *configparser.Section) error { s.Add("level", c...
/* * @lc app=leetcode.cn id=10 lang=golang * * [10] 正则表达式匹配 */ package main // @lc code=start func isMatch(s string, p string) bool { sLen := len(s) pLen := len(p) ret := make([][]bool, sLen+1) for i := 0; i < len(ret); i++ { ret[i] = make([]bool, pLen+1) } ret[0][0] = true for i := 0; i < pLen; i++ { ...
package queryexport import ( "bytes" "database/sql" "errors" "fmt" _ "github.com/go-sql-driver/mysql" _ "github.com/mattn/go-sqlite3" "github.com/tealeg/xlsx" "os" "path/filepath" "strings" ) type QEConf struct { User string Pass string Host string Port string DbName st...
package format import ( "bytes" "gollum/core" ) // SplitPick formatter // // This formatter splits data into an array by using the given delimiter and // extracts the given index from that array. The value of that index will be // written back. // // Parameters // // - Delimiter: Defines the delimiter to use when ...
package main import ( "crypto/tls" "log" "net/http" "os" "os/signal" "syscall" "github.com/tidepool-org/go-common/clients/version" "github.com/gorilla/mux" common "github.com/tidepool-org/go-common" "github.com/tidepool-org/go-common/clients" "github.com/tidepool-org/go-common/clients/disc" "github.com/...
package main import "fmt" //定义结构 type Block struct { //1,前区块哈希 PrevHash []byte //2,当前区块哈希 Hash []byte //3,数据 Data []byte } //2,创建区块 func NewBlock(data string,prevBlockHash []byte) *Block { block:=Block{ PrevHash:prevBlockHash,//先填空,后面再计算 //TODO Hash: []byte{}, Data: []byte(data), } return &block } ...
// Copyright 2017 VMware, Inc. 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...
// // response.go // Copyright (C) 2019 Grigorii Sokolik <g.sokol99@g-sokol.info> // // Distributed under terms of the MIT license. // package client import ( "encoding/json" "sync" ) type placeType string const ( PlaceTypeCity placeType = "city" PlaceTypeAirport placeType = "airport" ) type Response struct...
/** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func partition(head *ListNode, x int) *ListNode { if head == nil{ return head } var bh, bc, sh, sc *ListNode nd := head for nd != nil{ if nd.Val < x{ if sh ==...
package handlers import ( "fmt" "log" "net/http" "github.com/gorilla/mux" ) // WelcomeHandler - Handler func WelcomeHandler(w http.ResponseWriter, r *http.Request) { log.Printf("Handling /welcome") w.WriteHeader(http.StatusOK) fmt.Fprintf(w, "Welcome you!") } // WelcomeWithNameHandler - Handler func WelcomeW...
package testutil import ( "io/ioutil" "path/filepath" "testing" "github.com/stretchr/testify/require" "sigs.k8s.io/kustomize/v3/pkg/fs" "opendev.org/airship/airshipctl/pkg/document" ) // SetupTestFs help manufacture a fake file system for testing purposes. It // will iterate over the files in fixtureDir, whic...
package Util import ( "hash/crc32" ) /** 一致性hash函数 */ const multiple = 3 const hashLen = 1<<32 - 1 type HashFun func(str string) int type ConsistendHash interface { Add(string2 string) Get(string2 string) } func HashCrc(str string) int { return int(crc32.ChecksumIEEE([]byte(str))) } type hashMap struct { ...
package condenser import "github.com/weibocom/steem-rpc/types" type ChainProperties struct { AccountCreationFee string `json:"account_creation_fee"` MaximumBlockSize *types.Int `json:"maximum_block_size"` SbdInterestRate *types.Int `json:"sbd_interest_rate"` } type CurrentMedianHistoryPrice struct { Bas...
// Copyright 2023 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 log implements the relevant logging functions. */ package log import ( "log" "os" ) //variables for the different log types var ( Info *log.Logger //Important information Warning *log.Logger //Be concerned Error *log.Logger //Critical problem ) //initializes the logging functions func InitLog() ...
package fsm import ( "fmt" "math/rand" "reflect" "testing" "github.com/aws/aws-sdk-go/service/swf" . "github.com/sclasen/swfsm/log" . "github.com/sclasen/swfsm/sugar" ) func TestTrackPendingActivities(t *testing.T) { fsm := testFSM() fsm.AddInitialState(&FSMState{ Name: "start", Decider: func(f *FSMCon...
package main import "fmt" func main() { fmt.Println(suma(1, 2)) } func suma(first int, sec int) int { return first + sec }
package easy204 func countPrimes(n int) int { isNotPrime := make([]bool, n) var cnt int for i := 2; i < n; i++ { if !isNotPrime[i] { cnt++ for j := 2; i*j < n; j++ { isNotPrime[i*j] = true } } } return cnt }
package main type charGroup []byte var linebreak = charGroup{'\r', '\n'} var whitespace = charGroup{' ', '\t'} var quotes = charGroup{'\'', '"'} var lineDelim = charGroup{';'} var paramDelim = append(charGroup{','}, lineDelim...) var dupDelim = append(append(charGroup{}, paramDelim...), whitespace...) var i...
package apiclient import ( "context" "google.golang.org/grpc" clusterworkflowtmplpkg "github.com/argoproj/argo/pkg/apiclient/clusterworkflowtemplate" "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1" grpcutil "github.com/argoproj/argo/util/grpc" ) type errorTranslatingWorkflowClusterTemplateServiceClient s...
package postgres import ( "database/sql" "fmt" "os" _ "github.com/lib/pq" "github.com/rDybing/SignFindBackEnd/fileIO" ) // postgres URL String breakdown: // postgres://userName:userPassword@hostingservicePostgresURL:port/dbName var db *sql.DB // **********************************************...
package main import "fmt" func add(matrix1,matrix2 [2][2]int) [2][2]int { var m,l int var sum [2][2]int for l = 0; l<2; l++{ for m = 0; m < 2; m++{ sum[l][m] = matrix1[l][m] + matrix2[l][m] fmt.Println(sum) } } return sum } // subtract method func subtract(matrix1 [2][2]int, matrix2 [2][2]int) [2][2]...
package server import ( "context" "sync" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" uuid "github.com/satori/go.uuid" "github.com/sirupsen/logrus" "github.com/batchcorp/plumber-schemas/build/go/protos" "github.com/batchcorp/plumber-schemas/build/go/protos/args" "github.com/batchcorp/plumber-schema...
package coremidi import ( "testing" ) func TestNumberOfDevices(t *testing.T) { devices, err := AllDevices() numberOfDevices := len(devices) if err != nil { t.Fatalf("failed to get devices") } if numberOfDevices <= 0 { t.Fatalf("invalid number of devices") } } func TestManufacturer(t *testing.T) { devic...
/* Copyright 2012 gtalent2@gmail.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 applicable law or agreed to i...
package binance import ( "context" "net/http" ) // InterestHistoryService fetches the interest history type InterestHistoryService struct { c *Client lendingType LendingType asset *string startTime *int64 endTime *int64 current *int32 size *int32 } // LendingType sets the le...
package mongodb import ( "context" "fmt" "github.com/brigadecore/brigade/v2/apiserver/internal/api" "github.com/brigadecore/brigade/v2/apiserver/internal/lib/mongodb" "github.com/brigadecore/brigade/v2/apiserver/internal/meta" "github.com/pkg/errors" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-dr...
package stacker import ( "fmt" "path/filepath" "strconv" "strings" ) //StackEntry contains a single line or function call from the stack trace type StackEntry struct { Line int File string Path string } func parseLine(line string) StackEntry { tokens := strings.Split(line, ":") if len(tokens) < 2 { panic(...
package main // OK! 10'05 import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func nextInt() int { sc.Scan() i, e := strconv.Atoi(sc.Text()) if e != nil { panic(e) } return i } func main() { /* 初期化開始 */ sc.Split(bufio.ScanWords) n := nextInt() - 1 min := nextInt() for ; n > ...
// Copyright 2019 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 cmd import ( "errors" "fmt" "os" "path/filepath" "strings" "github.com/MYOB-Technology/pops/cmd/db" "github.com/MYOB-Technology/pops/cmd/random" "github.com/MYOB-Technology/pops/lib" "github.com/hashicorp/go-version" "github.com/olebedev/config" "github.com/spf13/cobra" ) var flagVersion bool var ...
// Licensed to SolID under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. SolID licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use this file except in compli...
package grpc import ( "testing" "github.com/stretchr/testify/require" "github.com/stackopsd/depo" ) func TestServerFactory(t *testing.T) { require.NoError(t, depo.VerifyFactory(new(ServerFactory))) } func TestServerOptionEmpty(t *testing.T) { require.NoError(t, depo.VerifyFactory(new(ServerOptionEmptyFactory)...
package Solution var idxMap map[int]int var p int func Solution(inorder []int, postorder []int) *TreeNode { p = len(postorder) - 1 idxMap = make(map[int]int) for i, v := range inorder { idxMap[v] = i } return build(0, len(inorder) - 1, postorder) } func build(left, right int, postorder []...
package main import ( "fmt" "math" ) func StringToIntArray(input string) []int { output := []int{} for _, v := range input { output = append(output, int(v)) } for i, j := 0, len(output)-1; i < j; i, j = i+1, j-1 { output[i], output[j] = output[j], output[i] } return output } func getInput(input string) (...
// Copyright 2019 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 dependency import ( "errors" "net/url" "regexp" ) // Package represents a single package. // This can be seen as the main unit of perseus. type Package struct { // Name is the name of the package (e.g. "twig/twig" or "symfony/console") Name string Repository *url.URL } // NewPackage will create a...
package main import ( "fmt" "os" ) func main() { // runes := []rune(os.Args[0]) // casting - преобразование типов . перевод типов. Мы переводим строку в массив Рун, // for _, letter := range runes { // тк индекс нам не нужен мы его пропускаем (for _,) затем переводим массив Рун в символы // z01.PrintRune(let...
package main import "fmt" //学生 type A struct { Name string age int } func (a *A) Say() { fmt.Printf("A say %v\n", a.Name) } func (a *A) hello() { fmt.Printf("A hello %v\n", a.Name) } type B struct { A Name string } func (b *B) Say() { fmt.Printf("B say %v\n", b.Name) } func main() { b1 := &B{} b1.Name = "...
// Copyright 2016-2021, Pulumi Corporation. package schema import ( "encoding/json" "fmt" "os" "path/filepath" "strings" jsschema "github.com/lestrrat-go/jsschema" "github.com/pkg/errors" "github.com/pulumi/pulumi/pkg/v3/codegen" dotnetgen "github.com/pulumi/pulumi/pkg/v3/codegen/dotnet" pschema "github.co...
package models import ( "encoding/xml" "errors" "io/ioutil" "log" "os" "strings" ) var ( indent = " " ) type Column struct { Name string `xml:"name,attr"` Type string `xml:"type,attr"` Length string `xml:"length,attr"` PK int64 `xml:"pk,attr"` NotNull int64 `xml:"notn...
package storage import ( "database/sql" _ "github.com/lib/pq" ) func NewPostgresConnection() (*sql.DB, error) { Connection, err := sql.Open("postgres", "postgres://postgres:@localhost:5432/go_recipes") if err != nil { return nil, err } if err = Connection.Ping(); err != nil { return nil, err } return Conn...
package main import ( "bytes" "crypto/hmac" "crypto/sha1" "encoding/base64" "fmt" "io/ioutil" "mime/multipart" "net/http" "strconv" "time" ) const ACR_OPT_REC_AUDIO string = "audio" const ACR_OPT_REC_HUMMING string = "humming" const ACR_OPT_REC_BOTH string = "both" type Recognizer struct { Host st...
// Copyright 2020 Clivern. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. package agent import ( "time" "github.com/clivern/walrus/core/module" "github.com/clivern/walrus/core/service" log "github.com/sirupsen/logrus" "github.com/spf13/v...
// Package sets contains set data structures. package sets
package main import ( "fmt" ) func main() { const ( a = iota b = iota c = iota ) fmt.Printf("a = %d, b = %d , c = %d \n", a, b, c) const d = iota fmt.Printf("d = %d\n", d) const ( a1 = iota b1 c1 ) fmt.Printf("a1 = %d, b1 = %d , c1 = %d ", a1, b1, c1) const ( i = iota j1, j2, j3...
/* * Go Library (C) 2017 Inc. * * @project Project Globo / avaliacao.com * @author @jeffotoni * @size 01/03/2018 */ package model // struct TPesqPerguntas type TPesqCurriculum struct { Uuid string `json:"uid"` Nome string `json:"nome"` Cpf string `json:"cpf"` Rg string `...
/** * Author: hashcode55 (Mehul Ahuja) * Created: 10.03.2017 **/ package gpython import ( "fmt" log "github.com/Sirupsen/logrus" "strings" "unicode/utf8" ) //##########################// // TYPE AND CONST DEFS // //##########################// // Token encapsulates a token using a type variable and...
package main import "fmt" func main() { eng := map[string]string{ "up": "above", "down": "below", } for k, v := range eng { fmt.Println("key=", k, "val=", v) } }
package handler import ( "context" "errors" "regexp" "github.com/jinmukeji/go-pkg/v2/areacode" "fmt" proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/user/v1" ) // UserValidateUsernameOrPhone 验证手机号码和用户名是否存在 func (j *JinmuIDService) UserValidateUsernameOrPhone(ctx context.Context, req *proto.Us...
package server import ( "errors" "fmt" "io" "math" "net" "os" "sort" "strconv" "strings" "sync" "time" "github.com/tidwall/buntdb" "github.com/tidwall/gjson" "github.com/tidwall/redcon" "github.com/tidwall/resp" "github.com/tidwall/tile38/internal/log" ) type errAOFHook struct { err error } func (e...
package main import "fmt" // File type file struct { name string } func (file) read(b []byte) (int, error) { s := "<rss><channel><title>Going Go Programming</title></channel></rss>" copy(b, s) return len(s), nil } // Pipe type pipe struct { name string } func (pipe) read(b []byte) (int, error) { s := `{name:...
package cosmos import "context" type UDF struct { client Client coll Collection udfID string } type UDFs struct { client Client coll Collection } func newUDF(coll Collection, udfID string) *UDF { coll.client.path = coll.client.path + "/udfs/" + udfID coll.client.rType = "udfs" coll.client.rLink = coll....