text
stringlengths
11
4.05M
/* Copyright (c) 2016 Jason Ish * 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 conditions...
package utils import ( "testing" "github.com/go-errors/errors" "github.com/stretchr/testify/assert" ) // TestSplitLines is a function. func TestSplitLines(t *testing.T) { type scenario struct { multilineString string expected []string } scenarios := []scenario{ { "", []string{}, }, { ...
package cache import ( "github.com/go-redis/redis/v7" "time" ) type Service interface { HSet(key string, values ...interface{}) error HSetNX(key string, field string, value interface{}, expiration time.Duration) (set bool, err error) Expire(key string, expiration time.Duration) error HGet(key string, field stri...
package core import ( "context" "github.com/borchero/switchboard/core/utils" "go.borchero.com/typewriter" apierrs "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8...
package session import ( "sync" ) type SessionStorage interface { Put(key string) Has(key string) bool Remove(key string) } type mapSessionStorage struct { storage map[string]bool lock *sync.RWMutex } func (s *mapSessionStorage) Put(key string) { s.lock.Lock() defer s.lock.Unlock() s.storage[key] = true }...
package main import "fmt" func main() { //1.创建一个可以存放3个int类型的管道 var intChan chan int intChan = make(chan int, 3) //2.看看intChan是什么 fmt.Printf("intChan 的值=%v intChan本身的地址=%p\n", intChan, &intChan) //3.向管道写入数据 intChan <- 10 intChan <- 90 intChan <- 100 //intChan <- 101 //fatal error: all goroutines are asleep -...
// package exec takes a core and config as input and completes one iteration, // returning any changed game conditions like terminated warriors package exec
package mysqldb import ( "context" "time" ) // UserPreferences 用户偏好 type UserPreferences struct { UserID int32 `gorm:"primary_key;column:user_id"` EnableHeartRateChart int32 // 是否开启心率扇形图 EnablePulseWaveChart int32 // 是否开启波形图 EnableWarmPrompt ...
package pathfileops import ( "fmt" "strings" "testing" ) const ( logDir = "../../logTest" commonDir = "../../pathfileops" ) func TestCleanDir(t *testing.T) { var expected, cleanDir, targetDir string fh := FileHelper{} targetDir = "../..///pathfileops" cleanDir = fh.CleanPathStr(targetDir) ex...
package resolver import ( "fmt" operatorsv1 "github.com/operator-framework/api/pkg/operators/v1" operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" v1listers "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/listers/operators/v1" "k8s.io/apimachinery/pkg/labels" )...
package main import "fmt" type Item struct { Next *Item Prev *Item Value interface{} } type List struct { FirstItem *Item LastItem *Item Lenght int } func main() { var newList List newList.PushFront(1) newList.PushFront(2) newList.PushBack(4) newList.PushFront(3) newList.PushBack(5) newList.Remov...
package health import ( "github.com/square/p2/pkg/types" ) // SortOrder sorts the nodes in the list from least to most health. type SortOrder struct { Nodes []types.NodeName Health map[types.NodeName]Result } func (s SortOrder) Len() int { return len(s.Nodes) } func (s SortOrder) Swap(i, j int) { s.Nodes[i], ...
// +build windows package process_exterminator func Init() error { return nil }
package cloud import ( "github.com/devspace-cloud/devspace/pkg/devspace/cloud/client" "github.com/devspace-cloud/devspace/pkg/devspace/cloud/config" "github.com/devspace-cloud/devspace/pkg/devspace/cloud/config/versions/latest" "github.com/devspace-cloud/devspace/pkg/devspace/docker" "github.com/devspace-cloud/de...
package user import "gorm.io/gorm" type User struct { gorm.Model Email string `gorm:"index:,unique,where: deleted_at is null" json:"email" validate:"email"` Password string `json:"string"` }
package graphql_test import ( "context" "reflect" "testing" "github.com/graphql-go/graphql" "github.com/graphql-go/graphql/testutil" ) type T struct { Query string Schema graphql.Schema Expected interface{} Variables map[string]interface{} } var Tests = []T{} func init() { Tests = []T{ { Que...
package collectors import ( "time" cfclient "github.com/cloudfoundry-community/go-cfclient" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/log" ) type ServiceInstancesCollector struct { namespace string environment ...
// Package delay is a CoreDNS plugin that sleeps for a configurable interval before passing to the next plugin // package delay import ( "context" "time" "github.com/coredns/coredns/plugin" clog "github.com/coredns/coredns/plugin/pkg/log" "github.com/miekg/dns" ) // Define log to be a logger with the plugin na...
// Copyright 2020 Ant Group. All rights reserved. // // SPDX-License-Identifier: Apache-2.0 package rule import ( "encoding/json" "fmt" "reflect" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/dragonflyoss/image-service/contrib/nydusify/pkg/parser" "github.com/dragonflyoss/image-service/con...
package repoimpl import ( "context" "strings" "sync" "williamfeng323/mooncake-duty/src/infrastructure/db" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) //AccountRepo is the implementation of Project repository type AccountRepo struct { c...
package streamview import ( "net" "time" ) type netMessages struct { message string addr net.UDPAddr timestamp time.Time } type StreamView struct { netChan chan netMessages udpPort string httpPort string } type SamplePKG struct { Power bool Execution bool Rand float64 HLimit int32 ...
// Copyright 2016 Kranz. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package base import "strings" func IsSliceContainsStr(sl []string, str string) (bool, string) { str = strings.ToLower(str) for _, s := range sl { if strings.ToLower...
/* * Copyright © 2018-2022 Software AG, Darmstadt, Germany and/or its licensors * * SPDX-License-Identifier: Apache-2.0 * * 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://...
package auth import ( "fmt" "testing" sdk "github.com/irisnet/irishub/types" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" ) func Test_queryAccount(t *testing.T) { input := setupTestInput() req := abci.RequestQuery{ Path: fmt.Sprintf("custom/%s/%s", "acc", QueryAcc...
// Copyright 2020 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...
// This file was generated for SObject DuplicateRecordSet, API Version v43.0 at 2018-07-30 03:47:32.341147216 -0400 EDT m=+18.684454745 package sobjects import ( "fmt" "strings" ) type DuplicateRecordSet struct { BaseSObject CreatedById string `force:",omitempty"` CreatedDate string `force:",omite...
package expr import ( "go/ast" "github.com/sky0621/go-testcode-autogen/inspect/result" "fmt" ) type InterfaceTypeInspector struct{} func (i *InterfaceTypeInspector) IsTarget(node ast.Node) bool { switch node.(type) { case *ast.InterfaceType: return true } return false } func (i *InterfaceTypeInspector) I...
// // Copyright (c) 2016-2022 Snowplow Analytics Ltd. All rights reserved. // // This program is licensed to you under the Apache License Version 2.0, // and you may not use this file except in compliance with the Apache License Version 2.0. // You may obtain a copy of the Apache License Version 2.0 at http://www.apach...
package api import ( "fmt" "net/http" "strconv" ) var listenersCh chan chan []byte func Listen(port int, listeners chan chan []byte) error { listenersCh = listeners http.HandleFunc("/api/pings", pingsHandler) return http.ListenAndServe(":"+strconv.Itoa(port), nil) } func pingsHandler(w http.ResponseWriter, r ...
/* * Copyright © 2018-2022 Software AG, Darmstadt, Germany and/or its licensors * * SPDX-License-Identifier: Apache-2.0 * * 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://...
package pool import ( "crawler/logger" "testing" "time" "gopkg.in/h2non/gock.v1" ) func init() { logger.Mute() } func TestStartTask(t *testing.T) { defer gock.Off() for _, hostname := range []string{"a.com", "b.com", "c.com", "e.com"} { gock.New("http://" + hostname).Get("/").Reply(200).BodyString("") } ...
package main // Auto generated file, do NOT edit! import ( "tetra/lib/factory" "tetra/lib/gui" ) var factoryRegisted bool // FactoryRegister register creator in factory for package main func FactoryRegister() { if factoryRegisted { return } factoryRegisted = true factory.Register(`main.Window`, func() inte...
package jwt import ( "crypto/hmac" "crypto/sha256" "encoding/base64" "encoding/json" "errors" "fmt" "strings" ) func Check(token, secret string) (jwtPayload, error) { var data jwtPayload tempSplitToken := strings.Split(token, ".") if len(tempSplitToken) != 3 { return data, errors.New("Invalid token format...
package main import ( "bytes" "encoding/json" "fmt" "github.com/nlopes/slack" "net/http" "os" "regexp" "sort" "time" ) func main() { cmdGitHub, _ := regexp.Compile("^!gh\\s([a-zA-Z0-9_]+)") api := slack.New( os.Getenv("SLACK_TOKEN"), // slack.OptionDebug(true), // slack.OptionLog(log.New(os.Stdout, ...
package chat import ( "fmt" "math/rand" "strings" "time" ) type slackClient interface { GetUserIDsInChannel(channelID string) ([]string, error) GetUserName(userID string) (string, error) PostMessage(channelID string, message string) error } type Service struct { slack slackClient } func NewService(client sl...
/* * Copyright @ 2020 - present Blackvisor Ltd. * * 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 ( "bufio" "fmt" "log" "net" ) func main() { ln, err := net.Listen("tcp", ":8080") if err != nil { log.Fatal(err) } defer ln.Close() for { conn, err := ln.Accept() if err != nil { log.Fatal(err) } go handleConnect(conn) } } func handleConnect(conn net.Conn) { //todo scanne...
package db import ( "errors" "fmt" "pencil/global" p_logger "pencil/utils/log" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" ) const ( DB_User = `user` ) type mysql struct { DataBaseUser *gorm.DB DataBaseVIP *gorm.DB } var ( MysqlService *mysql ) func init() { MysqlService = new(m...
package ch04 import "testing" // 4.2 思想不难理解,代码编写困难 // 采用分解矩阵,加减之后组合,把原来需要计算8次减少为只需要计算7次 func TestStrassen(t *testing.T) { arr := [][]int{} arr = append(arr, []int{1, 2, 3}) arr = append(arr, []int{1, 2, 3}) arr = append(arr, []int{1, 2, 3}) t.Log(squareMatrixMultiply(arr, arr)) } // n^2矩阵乘法 func squareMatrixM...
/* * @lc app=leetcode.cn id=91 lang=golang * * [91] 解码方法 */ // @lc code=start package main import "fmt" func main() { var s string s = "226" fmt.Println(numDecodings(s)) s = "12" fmt.Println(numDecodings(s)) } func numDecodings2(s string) int { // res := 0 // var dfs(int, int) // dfs = func(i, j int) {...
package main import "fmt" func main() { x := []int{12, 31, 6, 9, 102} fmt.Println(x) // y := []int{234, 77, 88, 99} // x = append(x, y...) // fmt.Println(x) x = append(x[:2], x[4:]...) // this is how you delete from slice // here we wanted to delete 2 elements of index 2 and 3 fmt.Println(x) }
package main import ( "bufio" "context" "flag" "fmt" "io" "io/ioutil" "log" "os" "strings" "sync" "time" "google.golang.org/grpc/metadata" "github.com/gocql/gocql" "github.com/webdevgopi/chatApp-gRPC/proto" "google.golang.org/grpc" ) var client proto.MessagingServiceClient var wait *sync.WaitGroup f...
package execext import ( "context" "errors" "io" "os" "path/filepath" "strings" "mvdan.cc/sh/expand" "mvdan.cc/sh/interp" "mvdan.cc/sh/shell" "mvdan.cc/sh/syntax" ) // RunCommandOptions is the options for the RunCommand func type RunCommandOptions struct { Command string Dir string Env []string ...
package control import ( "io" "net/http" "os" ) func IndexView(w http.ResponseWriter, r *http.Request) { f, _ := os.Open("./views/index.html") io.Copy(w, f) f.Close() } func DetailView(w http.ResponseWriter, r *http.Request) { f, _ := os.Open("./views/detail.html") io.Copy(w, f) f.Close() } func EditView...
package form3 import "time" // ClientOption defines an optional parameter for creating a form3.NewClient client. type ClientOption func(cl *Client) // WithRequestTimeout sets a maximum request timeout on the client for all requests. // Individual requests can be timeout out by context in a shorter time. The timeout ...
package codenames import ( "encoding/json" "fmt" "math" "time" "github.com/cockroachdb/pebble" ) // PebbleStore wraps a *pebble.DB with an implementation of the // Store interface, persisting games under a []byte(`/games/`) // key prefix. type PebbleStore struct { DB *pebble.DB } // Restore loads all persiste...
package main import ( "os" "github.com/sirupsen/logrus" "github.com/urfave/cli" ) func init() { logrus.SetLevel(logrus.DebugLevel) } func main() { app := cli.NewApp() app.Name = "startup-exporter" app.Usage = "A tool to collect and export container startup time" app.Commands = []cli.Command{ collectCmd, ...
package api import ( "bytes" "fmt" "io/ioutil" "mime/multipart" "net/http" "net/http/httptest" "os" "path/filepath" "testing" "time" "github.com/azzzak/fakecast/fs" "github.com/azzzak/fakecast/store" "github.com/stretchr/testify/assert" ) func TestSetCoverURL(t *testing.T) { cfg := &Cfg{ Host: "http:...
package main import ( "bytes" "fmt" "io/ioutil" "log" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/endpoints" "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/lexruntimeservice" "github.com/rmcsoft/hasp/sound" "golang.org/x/net/context" //"github.com...
package client type EmptyURL struct { } func (e EmptyURL) Error() string { return "missing urls" } type InvalidFlag struct { } func (i InvalidFlag) Error() string { return "flag parallel must be greater than zero" }
package main_test import ( "container/heap" Algo "AlgorithmAndDataStructure" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("AlgorithmAndDataStructure", func() { Describe("non modifying sequence", func() { var a []int var b []int var equal func(int, int) bool BeforeEach(func...
package models import ( "fmt" "github.com/devplayg/ipas-mcs/libs" "github.com/astaxie/beego/orm" "github.com/devplayg/ipas-mcs/objs" "time" "github.com/devplayg/ipas-server" ) func GetIpasStatusLog(filter *objs.IpasFilter, member *objs.Member) ([]objs.IpasLog, int64, error) { var where string var rows []objs....
package leetcodego func sortedListToBST(head *ListNode) *TreeNode { if head == nil { return nil } if head.Next == nil { return &TreeNode{Val: head.Val} } pre, slow, fast := head, head, head for fast != nil && fast.Next != nil { pre = slow slow = slow.Next fast = fast.Next.Next } pre.Next = nil tre...
package pkg import ( "bytes" "context" "encoding/json" "io/ioutil" "path" "github.com/allegro/bigcache" kit_log "github.com/go-kit/kit/log" weasel "github.com/revas-hq/weasel/pkg" ) type cache struct { Logger kit_log.Logger Cache *bigcache.BigCache Next weasel.Service } func NewCache(Logger kit_log.L...
package main import "syscall" import "os/exec" import "os" func main() { binary, _ := exec.LookPath("ls") args := []string{"xxxx", "-l", "-h"} // actually, the first argument of args will always be ignored // because Exec think the first argument as the name of program envs := os.Environ() err := syscall.Ex...
package main import ( json2 "encoding/json" "fmt" "log" "os" "strings" "syscall" "time" "github.com/fatih/color" "github.com/meilisearch/meilisearch-go" "golang.org/x/term" ) // MeiliSearch will index the sentences // on a given MeiliSearch instance. type MeiliSearch struct { client meilisearch.Cl...
package fileloader import "testing" func TestLoad(t *testing.T) { tests := []string{ "template/aws-api-lambda-golang/.gitignore.tmpl", "template/aws-api-lambda-golang/main.go.tmpl", "template/aws-api-lambda-golang/Makefile.tmpl", } for _, tt := range tests { t.Run("TestLoad", func(t *testing.T) { _, err...
package main import ( "errors" "fmt" ) func customError() { err := errors.New("bad emotion") fmt.Println(err) } func initPanic() { fmt.Println("start") panic("crash") fmt.Println("end") }
package myip import ( "errors" "github.com/qjpcpu/common/web" "github.com/qjpcpu/common/web/json" "strings" ) var ip_address string func ResolvePublicIP() string { if ip_address == "" { ip_address = resolvePublicIP() } return ip_address } func RefreshIP() string { ip_address = ResolvePublicIP() return ip...
package cli const ( // CLI command execution delay after the command is finished cliCmdExecFinishDelaySeconds = 5 )
package main import ( "fmt" "testing" ) func Test_checkStraightLine(t *testing.T) { tts := []struct { input [][]int expected bool }{ {[][]int{{1, 2}, {2, 3}, {3, 4}, {4, 5}, {6, 7}}, true}, {[][]int{{1, 1}, {2, 2}, {3, 4}, {4, 5}, {5, 6}, {7, 7}}, false}, } for _, tt := range tts { tt := tt t.R...
/* * Copyright 1999-2018 Alibaba Group. * * 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 a...
package 排列组合问题 // 回溯 + 外部变量 解决求数组组合问题 (数组中元素无重复且大于0,可重复选取) var combinationSequence [][]int func combinationSum(candidates []int, target int) [][]int { // 容量定义大点,这样可以避免扩容时产生额外时空花费 combinationSequence = make([][]int, 0, 100) combinationSumExec(candidates, target, make([]int, 0, 100)) return combinationSequence } fu...
package main import ( "net/http" "fmt" "io/ioutil" ) func main() { // var i int f, err := http.Get("https://raw.githubusercontent.com/dwyl/english-words/master/words_alpha.txt") if err != nil { fmt.Println(err) } defer f.Body.Close() a, err1 := ioutil.ReadAll(f.Body) if err != nil { fmt.Println(err1) ...
package scommon import ( "fmt" "runtime" "github.com/davecgh/go-spew/spew" ) func PrintPanicStack(extras ...interface{}) { if x := recover(); x != nil { //panicLog(fmt.Sprintf("%v", x)) i := 0 funcName, file, line, ok := runtime.Caller(i) for ok { i++ msg := fmt.Sprintf("PrintPanicStack. [func]: ...
package exoscale import ( "context" "testing" "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" ) func TestNodeAddresses(t *testing.T) { ctx := context.Background() p, ts := newMockInstanceAPI() instance := &instances{p: p} defer ts.Close() nodeAddress, err := i...
package main import ( "fmt" "math/rand" "sort" "strings" "time" ) func modify1(x int) { x = 100 } func modify2(x *int) { *x = 100 } func main() { a := 10 modify1(a) fmt.Println(a) modify2(&a) fmt.Println(a) var p *int fmt.Println(p) var p2 = new(int) fmt.Println(p2) *p2 = 200 fmt.Println(p2) fmt...
package transport import "github.com/zaynjarvis/fyp/dc/api" type CollectionService interface { Start() Stop() RecvNotification() <-chan *api.CollectionEvent SendConfig(*api.CollectionConfig) Services() []string } func New(port string, push bool) CollectionService { if push { return newPushModel(port) } pan...
// 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 object // PrivateUser represents PrivateUserObject // Link: https://developer.spotify.com/documentation/web-api/reference/#object-privateuserobject type PrivateUser struct { DisplayName string `json:"display_name,omitempty"` ID string `json:"id"` Country ...
package helper import ( "crypto/sha512" "encoding/base64" ) const passwordSalt = "a99VVoWzmd1C9ujcitK0fIVNE0I5I61AC47C852RoLTsHDyLCltvP+ZHEkIl/2hkzTOW90c3ZEjtYRkdfTWJ1Q==" // EncryptPassword helper func EncryptPassword(email, password string) string { hasher := sha512.New() hasher.Write([]byte(passwordSalt)) ha...
package game import ( "github.com/tanema/amore/gfx" ) // Voxel is the main drawn box type Voxel struct { x, y, z float32 width, height float32 h, s, l float32 shine float32 relative bool } func newVoxel(x, y, z, width, height, h, s, l float32, relative bool) *Voxel { return &Voxel{ ...
package conveyor type QueneBuckets struct { maxItems int quene []int totalSum int } func NewBuckets(maxItems int) *QueneBuckets { return &QueneBuckets{maxItems: maxItems} } func (q *QueneBuckets) Shift(shifted int) { if shifted > q.maxItems { q.quene = []int{} q.totalSum = 0 return } for shifted > 0...
package main import ( "fmt" "os" "net/http" "log" ) func main() { http.HandleFunc("/foo", higoHandler) log.Fatal(http.ListenAndServe(":8088", nil)) } func higoHandler(w http.ResponseWriter, r *http.Request) { name, err := os.Hostname() if err != nil { panic(err....
package actor import ( "fmt" "time" "github.com/stretchr/testify/mock" ) var nullProducer Producer = func() Actor { return nullReceive } var nullReceive ActorFunc = func(Context) {} var nilPID *PID func matchPID(with *PID) interface{} { return mock.MatchedBy(func(v *PID) bool { return with.Address == v.Addres...
package mqtt import ( "strconv" "strings" ) /////////////////////////////////////////////////////////////////////////////// type Subscription struct { ctx *Context // topic string topic *Topic qos byte next, prev *Subscription } func NewSubscription(ctx* Context, qos byte) (*Subscription){ sub := new...
package index import ( "fmt" "strings" ) func toTitle(filename string) string { r := strings.NewReplacer("_", " ", ".md", "") return strings.Title(r.Replace(filename)) } func wrapWithTag(content, tagName string) string { return fmt.Sprintf("<%s>%s</%s>", tagName, content, tagName) } func wrapWithAnchorTag(cont...
package reflectutils import ( "fmt" "reflect" "testing" ) type FileInfo struct { FileId int64 Uploader int64 CopyrightOwner int64 Name string Ext string Size int64 Sha string Title string Tag string Description string IpfsHas...
// ClueGetter - Does things with mail // // Copyright 2016 Dolf Schimmel, Freeaqingme. // // This Source Code Form is subject to the terms of the two-clause BSD license. // For its contents, please refer to the LICENSE file. // package elasticsearch import ( "encoding/hex" "encoding/json" "time" "cluegetter/addre...
package main import "fmt" func main() { var c1 byte = 'a' var c2 byte = '0' // 直接输出是ASCII码值 fmt.Println("c1 =", c1) fmt.Println("c2 =", c2) // 输出字符需要格式化输出 fmt.Printf("c1=%c c2=%c \n", c1, c2) // 中文是unicode,不能用byte var c3 int = '北' fmt.Printf("c3=%c 对应的码值是%d \n", c3, c3) var c4 int = 22269 fmt.Printf("c4...
package main import ( "fmt" "github.com/littleajax/adventofcode/days/day12" "github.com/littleajax/adventofcode/days/day10" "github.com/littleajax/adventofcode/days/day7" "github.com/littleajax/adventofcode/days/day8" "github.com/littleajax/adventofcode/days/day9" "github.com/littleajax/adventofcode/days/day...
package timeformat import ( "testing" "time" ) func TestFormatString(t *testing.T) { inputs := []struct { in string want string }{ {in: "YYYY", want: "2006"}, {in: "YY", want: "06"}, {in: "MMMM", want: "January"}, {in: "MMM", want: "Jan"}, {in: "MM", want: "01"}, {in: "M", want: "1"}, {in: "DD...
/* You have a large electronic screen which can display up to 998244353 decimal digits. The digits are displayed in the same way as on different electronic alarm clocks: each place for a digit consists of 7 segments which can be turned on and off to compose different digits. The following picture describes how you can...
package main import ( "fmt" "sync" appConfig "github.com/anuj-verma/profilopedia/config" services "github.com/anuj-verma/profilopedia/services" "github.com/dghubble/go-twitter/twitter" ) func fetchGithubData(wg *sync.WaitGroup) { // Decrement the counter when the goroutine completes. defer wg.Done() githubCl...
package main import ( "fmt" "os" "github.com/odpf/stencil/cmd" ) const ( exitOK = 0 exitError = 1 ) func main() { command := cmd.New() if err := command.Execute(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(exitError) } }
package pg import ( "github.com/kyleconroy/sqlc/internal/sql/ast" ) type ArrayRef struct { Xpr ast.Node Refarraytype Oid Refelemtype Oid Reftypmod int32 Refcollid Oid Refupperindexpr *ast.List Reflowerindexpr *ast.List Refexpr ast.Node Refassgnexpr ast.Node } func ...
package config import "os" var ( AccessID = os.Getenv("OSS_ACCESS_KEY_ID") AccessKey = os.Getenv("OSS_ACCESS_KEY_SECRET") BucketName = os.Getenv("OSS_BUCKET") Endpoint = os.Getenv("OSS_ENDPOINT") )
package models import "gopkg.in/mgo.v2/bson" type Prefecture struct { Id int `json:"id" bson:"_id"` Name string `json:"name" bson:"name"` Romaji string `json:"romaji" bson:"romaji"` } type Prefectures struct { Prefectures []Prefecture `json:"prefectures"` } func G...
/* -Calculadora simple -Contiene suma,resta,multiplicación y división -Uso fácil en terminal -Esta calculadora solo contempla dos valores en cualquier operación */ package main import ( "fmt" "os" "os/exec" "time" "strconv" "github.com/fatih/color" ) func main() { Limpiar() Banner() Tiempo() Cal...
// Copyright 2017 orijtech, 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 applic...
// ------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // -----------------------------------------------------------------...
// 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 main import ( "flag" "github.com/golang/dep" "github.com/golang/dep/gps" "github.com/golang/dep/gps/pkgtree" "github.com/pkg/errors" ) func (cmd...
package main import ( "fmt" "net/http" "strconv" "sync" "time" ) // Debug is used for more verbose output messages var Debug bool var guesses []Guess var scannerConfig ScannerConfig var successfullLogins map[TcInstance]Guess var version = "1.1.0" var kudos = "By Michael Eder. @edermi on Github, @michael_eder_ o...
package event import ( "context" "github.com/dwaynelavon/es-loyalty-program/internal/app/eventsource" "github.com/dwaynelavon/es-loyalty-program/internal/app/loyalty" "github.com/dwaynelavon/es-loyalty-program/internal/app/user" "github.com/pkg/errors" "go.uber.org/zap" ) type saga struct { dispatcher even...
package data import ( "errors" "fmt" "io" "log" "net/http" "os" "github.com/souhub/wecircles/pkg/logging" ) type Circle struct { ID int Name string ImagePath string Overview string Category string OwnerID int OwnerIDStr string OwnerImagePath string Tw...
package main import "fmt" type student struct{ rollno int name string } func (s *student) getRollNo() int{ return s.rollno } func (s *student) getName() string{ return s.name } func main(){ obj1 := student{name: "sushil", rollno: 16107} fmt.Println("whole obj\t", obj1) fmt.Println("address of object\t", &o...
package main import "fmt" import "./testb" func main() { fmt.Printf("Hello world!\n") testb.Testa() Testd() coucou() } func coucou() { fmt.Printf("coucou\n") }
package repository import ( "service-consult/service" _ "github.com/go-sql-driver/mysql" ) const ( Username = "root" Password = "admin" Hostname = "mysql:3306" DBName = "testeDB" ) type Storage interface { ConsultNegativacoes(data string) ([]*service.Data, error) }
package update import ( "archive/tar" "bytes" "compress/gzip" "encoding/json" "fmt" "io" "net/http" "os" "os/exec" "path/filepath" "runtime" "time" "github.com/fd/forklift/root" "github.com/fd/forklift/static/gopkg.in/fd/go-cli.v1/cli" ) func init() { cli.Register(Update{}) } type Update struct { ro...
package main import ( "fmt" ) // 350. 两个数组的交集 II // 给定两个数组,编写一个函数来计算它们的交集。说明: // 输出结果中每个元素出现的次数,应与元素在两个数组中出现的次数一致。 // 我们可以不考虑输出结果的顺序。 // 进阶: // 如果给定的数组已经排好序呢?你将如何优化你的算法? // 如果 nums1 的大小比 nums2 小很多,哪种方法更优? // 如果 nums2 的元素存储在磁盘上,磁盘内存是有限的,并且你不能一次加载所有的元素到内存中,你该怎么办? // 来源:力扣(LeetCode) // 链接:https://le...