text
stringlengths
11
4.05M
package metrics var ( namespace = `taoblog` subsystem = `` ) func bool2string(v bool) string { if v { return `1` } return `0` }
package vc import ( "crypto/sha1" "fmt" "io/ioutil" "log" "os" "path/filepath" ) func HashObject(path string) { data, err := ioutil.ReadFile(path) if err != nil { log.Fatalf("Error reading file [%v] - %v", path, err) } fmt.Println(hashObject(data, "blob")) } func hashObject(data []byte, type_ string) str...
package config import ( "fmt" "io/ioutil" "gopkg.in/yaml.v3" formatter_api "github.com/cyberark/secretless-broker/bin/juxtaposer/formatter/api" ) // Config is the main structure used to define the perfagent parameters type Config struct { Backends map[string]Backend `yaml:"backends"` ...
package main import ( idx "../index" "bytes" "encoding/json" "flag" "fmt" "io/ioutil" "log" "strconv" "net/http" "os" "os/exec" "strings" "path" "time" ) var SRC *string var INDEX *string var URL *string type repository struct { Url string Dir string } func (r *repository) exec(name string, arg ...s...
package main import ( "fmt" "image" "os" "github.com/borkshop/bork/internal/bitmap" "github.com/borkshop/bork/internal/cops/braille" "github.com/borkshop/bork/internal/cops/display" ) func main() { if err := run(); err != nil { fmt.Printf("%v\n", err) } } func run() (err error) { w, h := 32, 16 pb := im...
/* Copyright 2021 The KodeRover 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, s...
// Copyright (C) 2016-Present Pivotal Software, Inc. All rights reserved. // This program and the accompanying materials are made available under the terms of the 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 Licen...
package netmgr import ( . "github.com/ajruckman/xlib" "github.com/ajruckman/ContraCore/internal/db/contralog" "github.com/ajruckman/ContraCore/internal/schema" "github.com/ajruckman/ContraCore/internal/system" ) // The maximum number of logs in the query log cache. const cacheSize = 5000 // A slice containing t...
package main import ( "github.com/kr/pretty" ) func generate(numRows int) [][]int { if numRows == 0 { return [][]int{} } ans := make([][]int, 0, numRows) for i := 1; i <= numRows; i++ { tmp := make([]int, i) tmp[0], tmp[len(tmp)-1] = 1, 1 for j := 1; j < i-1; j++ { tmp[j] = ans[len(ans)...
// A simple rest client // based on: // - https://medium.com/@marcus.olsson/writing-a-go-client-for-your-restful-api-c193a2f4998c // - https://golang.org/pkg/net/http/ // - https://golang.org/pkg/io/ioutil/ // author: andreasl package main import ( "fmt" "io/ioutil" "net/http" ) // dispatch a GET request an...
package handlers import ( "fmt" "net/http" ) type ProjectedHandler struct { } func (handler *ProjectedHandler) ServeHTTP(writer http.ResponseWriter, httpRequest *http.Request) { fmt.Println(httpRequest) }
package log import ( "fmt" "os" "strconv" "go.uber.org/zap" ) var _logger *zap.SugaredLogger var _debugMode bool func init() { // 从环境变量读取Debug模式 if v, ok := os.LookupEnv("APP_DEBUG"); ok { if v, err := strconv.ParseBool(v); err == nil { _debugMode = v } } // 初始化日志记录器 _logger = newZapLogger() } fun...
package main import ( "strings" "time" "intra-hub/confperso" "intra-hub/db" _ "intra-hub/models" _ "intra-hub/routers" _ "intra-hub/tasks" "encoding/json" "github.com/astaxie/beego" "github.com/astaxie/beego/orm" _ "github.com/astaxie/beego/session/mysql" "github.com/beego/i18n" "github.com/eknkc/datefo...
package termite import ( "fmt" "log" "os" "sync" "time" "github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse/nodefs" ) var _ = log.Println type lazyLoopbackFile struct { nodefs.File mu sync.Mutex f nodefs.File Name string } func NewLazyLoopbackFile(n string) nodefs.File { return &lazy...
// Copyright 2019 Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in complian...
package Product_of_Array_Except_Self func productExceptSelf(nums []int) []int { if len(nums) < 2 { return nums } var result = make([]int, len(nums)) var left = 1 var right = 1 for i := 0; i < len(nums); i++ { result[i] = left left *= nums[i] } for i := len(nums) - 1; i >= 0; i-- { result[i] *= right...
/* Name : Kamil KAPLAN Date : 25.07.2019 */ package models type AdministrativeArea struct { ID string `json:"ID,omitempty"` LocalizedName string `json:"LocalizedName,omitempty"` EnglishName string `json:"EnglishName,omitempty"` Level int32 `json:"Level,omitempty"` LocalizedType ...
// Copyright 2018 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 assumeMethod import "fmt" type User struct { Name string Email string } func (u *User) Notify() { fmt.Printf("%v : %v\n", u.Name, u.Email) } //当接受者不是一个指针时,该方法操作对应接受者的值的副本(意思就是即使你使用了指针调用函数,但是函数的接受者是值类型,所以函数内部操作还是对副本的操作,而不是指针操作。 //当接受者是指针时,即使用值类型调用那么函数内部也是对指针的操作。 func UseNotify() { u1 := User{ "enoch"...
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package capturemode contains helper methods to work with Capture Mode. package capturemode import ( "context" "strings" "time" "chromiumos/tast/errors" "chromiumos/...
package websocket import ( "log" "sync" "time" websocket "github.com/gorilla/websocket" ) /** This file can be used to send/receive messages across/from a websocket connection. The supported binary format is protobuf. */ type WebSocket interface { Send([]byte) error // send a message to the brows...
package acmetool_account_thumbprint import ( "fmt" "github.com/hlandau/acme/acmeapi/acmeutils" "github.com/hlandau/acme/acmetool" "github.com/hlandau/acme/storage" ) func Register(app *acmetool.App) { app.CommandLine.Command("account-thumbprint", "Prints account thumbprints") app.Commands["account-thumbprint"]...
package c // Token Type const ( TokenTypeLogin = "login" ) // Token Obtained By const ( TokenObtainedBySignup = "sign-up" TokenObtainedByLogin = "login" )
package pkg import ( "net/http" "net/http/httptest" "testing" ) func TestSetupRouter(t *testing.T) { tests := []struct { name string verb string route string want int }{ {"POST not allowed", "POST", "/word", 405}, {"PUT not allowed", "PUT", "/word", 405}, {"DELETE not allowed", "DELETE", "/word...
package logdb import ( "encoding/binary" "fmt" "testing" "github.com/stretchr/testify/assert" ) var coderTypes = map[string]func() *CodingDB{ "id": func() *CodingDB { return IdentityCoder(&InMemDB{}) }, "binary": func() *CodingDB { return BinaryCoder(&InMemDB{}, binary.LittleEndian) }, "gob": func() *C...
package helper import ( "github.com/stretchr/testify/assert" "runtime" "testing" ) func TestUtils_init(t *testing.T) { if runtime.GOOS == "linux" { assert.Equal(t, IsGnuTar, true) } else { assert.Equal(t, IsGnuTar, false) } }
package main import "fmt" /* Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of them. If there are less than 2k but greater than or equal to k characters, then reverse the f...
package main import ( "fmt" "io" ) type MifWriter struct { w io.Writer } func NewMifWriter(w io.Writer) (ww *MifWriter) { fmt.Fprint(w, "WIDTH=32;\n") fmt.Fprint(w, "DEPTH=1024;\n") fmt.Fprint(w, "ADDRESS_RADIX=HEX;\n") fmt.Fprint(w, "DATA_RADIX=HEX;\n") fmt.Fprint(w, "CONTENT BEGIN\n") return &MifWriter{w:...
package ui import "image/color" // Color ... type Color color.Color // ... var ( Black = color.Black White = color.White Red = color.RGBA{255, 0, 0, 255} Green = color.RGBA{0, 255, 0, 255} Blue = color.RGBA{0, 0, 255, 255} Yellow = color.RGBA{255, 255, 0, 255} Purple ...
package service import ( "crypto/md5" "fmt" "io" "scratch_maker_server/models" "strconv" ) func GetUserList(pageNum, pageSize, nameQuery string) []models.User { models.Db.LogMode(true) var userList []models.User pageSizeInt, err := strconv.Atoi(pageSize) if err != nil { fmt.Println("err", err) } pageNum...
package web import ( "bytes" "encoding/json" ) var ( errMethodNotAllowed = newJSONError("method_not_allowed", "method not allowed") errEmptyQuery = newJSONError("empty_query", "query cannot be empty") errMissingType = newJSONError("missing_envelope_type", "query must prov...
// // Copyright (c) 2019-2021 Red Hat, Inc. // This program and the accompanying materials are made // available under the terms of the Eclipse Public License 2.0 // which is available at https://www.eclipse.org/legal/epl-2.0/ // // SPDX-License-Identifier: EPL-2.0 // // Contributors: // Red Hat, Inc. - initial API a...
package crypto import "encoding/json" type BinTicker struct { Name string `json:"symbol"` Price string `json:"price"` } func (*BinTicker) GetData() (interface{}, error) { data, err := getTickersData("https://api.binance.com/api/v3/ticker/price") if err != nil { return nil, err } ticks := make([]*BinTicker, ...
// SPDX-License-Identifier: MIT package lsp import ( "io/ioutil" "log" "testing" "github.com/issue9/assert/v3" "github.com/caixw/apidoc/v7/core" "github.com/caixw/apidoc/v7/core/messagetest" "github.com/caixw/apidoc/v7/internal/ast" "github.com/caixw/apidoc/v7/internal/lsp/protocol" ) func loadReferencesDo...
package gueditor import "fmt" func log(info interface{}) { fmt.Printf("%+v\n", info) }
package core import ( "fmt" ) //定义地图结构体 type AOIManager struct { //区域的左边边界 MinX int //区域的右边边界 MaxX int //X轴方向格子的数量 CntsX int //区域的上边边界 MinY int //区域的下边边界 MaxY int //Y轴方向的格子的数量 CntsY int //整体区域(地图中)拥有哪些格子map:key格子ID,value:格子对象 grids map[int]*Grid } //得到每个格子在X轴的宽度 func (m *AOIManager) GridWidth() int { ...
// project euler (projecteuler.net) problem 70 // solution by Kevin Retzke (retzkek@gmail.com), May 2012 package main import ( "fmt" "math" ) type Primes struct { Primes []int Last int } // Init initializes a Primes struct with the first two primes. func (p *Primes) Init() { p.Primes = []int{2, 3} p.Last = 3...
package messaging import ( "time" ) const ( ADD string = "ADD" DELETE string = "DEL" MODIFIED string = "MOD" ) type AdvertisementMessage struct { AppName string `json:"app_name"` BaseNode string `json:"base_node"` Type string `json:"type"` Components []Component `json:"components"`...
package _017_Letter_Combinations_of_a_Phone_Number import ( "testing" "github.com/stretchr/testify/assert" ) func TestLetterCombinations(t *testing.T) { ast := assert.New(t) ast.EqualValues([]string{"ad", "bd", "cd", "ae", "af", "be", "bf", "ce", "cf"}, letterCombinations("23")) ast.EqualValues([]string{"p...
// Copyright 2015 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 consensus import ( "errors" "runtime" "github.com/NebulousLabs/Sia/crypto" "github.com/NebulousLabs/Sia/encoding" "github.com/NebulousLabs/Sia/modules" "github.com/NebulousLabs/Sia/types" ) const ( MaxCatchUpBlocks = 10 MaxSynchronizeAttempts = 8 ) // blockHistory returns up to 32 BlockIDs, st...
package main import ( "fmt" "reflect" ) func main() { cases := []struct { in string exp []string }{ {"a", []string{"a"}}, {"ab", []string{"ab", "ba"}}, {"abc", []string{"abc", "acb", "bac", "bca", "cba", "cab"}}, } for _, tc := range cases { act := permutation(tc.in) if reflect.DeepEqual(tc.exp,...
/** * @description: 切片的copy方法 * @author Administrator * @date 2020/7/11 0011 10:44 */ package main import "fmt" func main() { //由于切片是引用类型,所以a和b其实都指向了同一块内存地址。修改b的同时a的值也会发生变化 a := []int{1, 2, 3, 4, 5} b := a fmt.Println(a) //[1 2 3 4 5] fmt.Println(b) //[1 2 3 4 5] b[0] = 1000 fmt.Println(a) //[1000 2 3 4 5]...
package leetcode func imageSmoother(img [][]int) [][]int { m, n := len(img), len(img[0]) preSum, ans := make([][]int, m+1), make([][]int, m) preSum[0] = make([]int, n+1) for i := 0; i < m; i++ { preSum[i+1] = make([]int, n+1) ans[i] = make([]int, n) for j := 0; j < n; j++ { preSum[i+1][j+1] = preSum[i+1...
// Copyright 2015 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 adminconsole import ( "context" "fmt" "github.com/epmd-edp/admin-console-operator/v2/pkg/controller/helper" "github.com/epmd-edp/admin-console-operator/v2/pkg/service/admin_console" "github.com/epmd-edp/admin-console-operator/v2/pkg/service/platform" "os" "time" edpv1alpha1 "github.com/epmd-edp/admin-...
package structs import ( "github.com/UniversityRadioYork/myradio-go" ) type TimeslotTemplateData struct { Timeslot myradio.Timeslot Config Config } type CalendarTemplateData struct { Show myradio.ShowMeta User myradio.User Config Config }
package main import ( "fmt" "strconv" "math" ) // https://projecteuler.net/problem=36 func same_both_ways(s string) bool{ same := true if(string([]byte{s[0]}) == "0" || string([]byte{s[len(s) - 1]}) == "0"){ return false; } for i := 0; i < len(s); i++ { if(s[i] == s[len(s) - i - 1]){ // fmt.Println(...
package packets import ( "io" "bytes" ) type PingreqPacket struct { FixedHeader } func (pr *PingreqPacket) Write(w io.Writer) error { var body bytes.Buffer body.WriteByte(pr.FixedHeader.MessageType << 4) body.WriteByte(0) _, err := w.Write(body.Bytes()) ...
package service // Context holds interfaces of external services type Context struct { } // Request is a request object for ... type Request struct { } // Response is a response object for ... type Response struct { }
package tools import ( "runtime" "strings" ) /******************************************************************** created: 2020-06-13 author: lixianmin Copyright (C) - All Rights Reserved *********************************************************************/ func CallersFrames(skip int, fullStack bool) []...
package main import "gopkg.in/alecthomas/kingpin.v1" var ( searchCommand = kingpin.Command("search", "search for packages").Dispatch(search) ) func search(c *kingpin.ParseContext) error { return nil }
// Copyright 2018 Saferwall. All rights reserved. // Use of this source code is governed by Apache v2 license // license that can be found in the LICENSE file. // Package log provides context-aware and structured logging capabilities. package log import ( "context" "go.uber.org/zap" "go.uber.org/zap/zapcore" "go...
package e7_5 import ( "io" ) type limitReader struct { reader io.Reader limit int64 pos int64 } func LimitReader(r io.Reader, n int64) io.Reader { return &limitReader{reader: r, limit: n} } func (lr *limitReader) Read(p []byte) (n int, err error) { var readLen int64 if lr.pos == lr.limit && len(p) > 0 {...
package powerblink import "testing" func Test色の加算テスト(t *testing.T) { lhs := Color{0, 0, 0} rhs := Color{100, 100, 100} ans := lhs.Add(rhs) if ans.Red != 100 { t.Error("Red != 100", ans.Red) } if ans.Green != 100 { t.Error("Green != 100", ans.Green) } if ans.Blue != 100 { t.Error("Blue != 100", ans.G...
package types type InstallUbuntu struct { Comport string `json:"comport"` CompletionUri string `json:"completionUri"` Domain string `json:"domain"` Hostname string `json:"hostname"` Password string `json:"password"` Profile string `json:"profile"` UID int `json:"uid"` ...
package main import "fmt" func main() { array := []int{48,96,86,68,57,82,63,70,37,34,83,27,19,97,9,17,} smallestNumber := array[0] for _, element := range array { if element < smallestNumber { smallestNumber = element } } fmt.Println("Smallest number is ", smallestNumber) }
package ravendb import ( "net/http" ) var ( _ RavenCommand = &GetSubscriptionStateCommand{} ) // GetSubscriptionStateCommand describes "get subscription state" command type GetSubscriptionStateCommand struct { RavenCommandBase subscriptionName string Result *SubscriptionState } func newGetSubscriptionStateCo...
package queue import ( "context" "fmt" "time" "github.com/mongodb/mongo-go-driver/bson" "github.com/mongodb/mongo-go-driver/bson/primitive" "github.com/mongodb/mongo-go-driver/mongo" "github.com/mongodb/mongo-go-driver/mongo/options" ) // QueueMessage is the queue message structure. type QueueMessage struct {...
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/models" "context" "errors" ) func (r *mutationResolver) CreateCategory(ctx context.Context, inpu...
/* Copyright 2015 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, ...
package client import ( "fmt" "github.com/DataDog/datadog-agent/pkg/util/log" "github.com/gorilla/websocket" "proxy/config" "proxy/impl" "time" ) var retryTimes = 1 // 连接客户端,向客户端中转数据 func StartClient() { log.Info("client start.....") fmt.Println(" client start .....") conf := config.ConfigVal("config") con...
// Package thisconf is a simple package to do things that Viper doesn't. package thisconf import ( "github.com/spf13/viper" "github.com/utrack/goroadie" ) // Load loads app config from files & env variables. Config structure // is whatever you like (and whatever the libs are able to unmarshal into). func Load(conf ...
package main import ( "html/template" "io" "net/http" "os" "github.com/julienschmidt/httprouter" ) func main() { r := httprouter.New() //curl -XGET -vvv http://127.0.0.1:9999/posts/my-second-post //curl -XGET -vvv http://127.0.0.1:9999/posts/wrong_path r.GET("/posts/:title", func(w http.ResponseWriter, r ...
package service func (s *Service) ExamPaperAnswerSelectAllCount() int { return s.examService.ExamPaperAnswerSelectAllCount() }
package editor import ( "api/base" "encoding/json" "fmt" ) // type User base.User func (user *User) Save() { jsonStr, err := json.Marshal(user) if err != nil { fmt.Println("json user is error") } baseProvider.User.RedisProvider.SetUserInfo(user.UserId, string(jsonStr)) //进行mongo存储 } func GetUserEditor(us...
package main import ( "net/http" "github.com/gin-gonic/gin" ) // IndexHandler 主页处理函数 func IndexHandler(c *gin.Context) { c.HTML(http.StatusOK, "index.html", gin.H{ "msg": "嘿嘿嘿", }) } func main() { engine := gin.Default() engine.LoadHTMLGlob("templates/*") engine.Static("/static", "./statics") engine.GET("...
package gs15 const ( FullLen = 15 MasterLen = 14 )
package replacespaces import ( "fmt" "golangexercises/arraysandstrings/util" "strings" "testing" "time" ) const ( myName = "My name is a secret and I live in Utah " myNameReplaced = "My%20name%20is%20a%20secret%20and%20I%20live%20in%20Utah" ) func TestReplace(t *testing.T) { if r :=...
package raft import ( "bytes" "encoding/gob" "fmt" "log" "math/rand" "os" "sync" "sync/atomic" "time" ) const DebugCM = 1 /* CommitEntry就是Raft向提交通道发送的数据。每一条提交的条目都会通知客户端, 表明指令已满足一致性,可以应用到客户端的状态机上。 */ type CommitEntry struct { // Command 是被提交的客户端指令 Command interface{} // Index 是被提交的客户端指令对应的日志索引 Index i...
package form3client import ( "encoding/json" "io/ioutil" "net/http" "net/http/httptest" "strconv" "testing" ) type test struct { status int } func createClient() Form3Client { client := Form3Client{} client.New() return client } func readAccountSampleData() ([]byte, error) { filename := "testdata/account...
// 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 firmware import ( "context" "io/ioutil" "os" "path/filepath" "time" "chromiumos/tast/common/testexec" "chromiumos/tast/local/bundles/cros/firmware/fwupd" "c...
package requests import ( "encoding/json" "fmt" "io/ioutil" "net/url" "strings" "github.com/google/go-querystring/query" "github.com/atomicjolt/canvasapi" "github.com/atomicjolt/canvasapi/models" ) // CreateLineItem Create a new Line Item // https://canvas.instructure.com/doc/api/line_items.html // // Path ...
// 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 proto2gql import ( "fmt" "reflect" "strings" "github.com/pkg/errors" "github.com/EGT-Ukraine/go2gql/generator/plugins/graphql" "github.com/EGT-Ukraine/go2gql/generator/plugins/proto2gql/parser" ) func (g Proto2GraphQL) serviceMethodArguments(file *parsedFile, method *parser.Method) ([]graphql.MethodAr...
// Copyright 2018 xgfone // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writi...
package list import ( "github.com/JiBadBoy/gods/containers" ) type List interface { }
package hive import "gmf" func CreateEncoder(codec * Codec)*gmf.Encoder{ result:=new(gmf.Encoder) result.SetParameter("codecid",codec.Id) for i:=0;i<len(codec.Param);i++{ result.SetParameter(codec.Param[i].Name,codec.Param[i].Value) } return result }
/** a small chat room can use @ to talk to someone ➜ ~ nc localhost 8888 [2017-07-20 17:54:30][admin] hi tourist-1, welcome to chat room! 大家好 [2017-07-20 17:54:35][tourist-1] 大家好 @tourist-0 你好啊 [2017-07-20 17:55:03][tourist-0] 哈哈,你好 大家好 [2017-07-20 17:56:06][tourist-1] 大家好 */ package main import ( "bufio" "log" "...
package graph import ( "context" "graphqltest/graph/generated" "graphqltest/models" ) func (r *documentResolver) User(ctx context.Context, obj *models.Document) (*models.User, error) { return GetUserLoader(ctx).Load(obj.UserId) } func (d documentResolver) Description(ctx context.Context, obj *models.Document) (...
package innerrpc //THIS MODULE INITIALIZES RPC CONNECTION TO DATA PROVIDE import ( "time" "splitter/config" ) var ( DataClient *Client err error dns = config.DATASERVER_IP + config.DBSERVER_RPC_PORT ) func Start() { //Dial Data Provider DataClient, err = NewClient(dns, time.Millisecond*500) }
package plusone import ( "reflect" "testing" ) func TestPlusOne(t *testing.T) { tests := []struct { in []int want []int }{ { in: []int{1, 2, 3}, want: []int{1, 2, 4}, }, { in: []int{4, 3, 2, 1}, want: []int{4, 3, 2, 2}, }, { in: []int{0}, want: []int{1}, }, { in: [...
package solutions func reverseVowels(s string) string { result := []byte(s) for i, j := 0, len(s) - 1; i < len(s) && j > i ; i++ { if isVowel(s[i]) { for j >= i && !isVowel(s[j]) { j-- } result[i], result[j] = result[j], result[i] j-- ...
// Copyright 2020 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 ( "fmt" ) type ( Category struct { Name string } Post struct { Title string } ) func (c Category) lihatData() { fmt.Println(c) } func (p Post) lihatData() { fmt.Println(p) } func main() { fmt.Printf("From Category\n") cats := Category{ Name: "Berita", } cats.lihatData() fmt....
package db import ( "errors" "fmt" ) type Config struct { Host string `json:"host"` Port int `json:"port"` Username string `json:"username"` Password string `json:"password"` Name string `json:"name"` SSLMode string `json:"ssl_mode"` } func (c Config) PostgresURL() (string, error) { if c.Hos...
package siprocket /* RFC 3261 - https://www.ietf.org/rfc/rfc3261.txt - 8.1.1.7 Via The Via header field indicates the transport used for the transaction and identifies the location where the response is to be sent. A Via header field value is added only after the transport that will be used to reach the next hop h...
package cli import ( "context" "fmt" "log" "time" "github.com/fatih/color" "github.com/mattn/go-colorable" "github.com/spf13/cobra" "github.com/tilt-dev/tilt/internal/analytics" "github.com/tilt-dev/tilt/internal/hud/prompt" "github.com/tilt-dev/tilt/internal/store" "github.com/tilt-dev/tilt/pkg/logger" ...
package store_test import ( "testing" "github.com/dhui/dktest" "github.com/stretchr/testify/require" . "nidavellir/services/store" ) func TestNewSecret(t *testing.T) { t.Parallel() assert := require.New(t) tests := []struct { SourceId int Key string Value string HasError bool }{ {0, "Key"...
// Copyright 2017 Google 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 applicabl...
package gormzap import ( "fmt" "time" "github.com/jinzhu/gorm" "go.uber.org/zap" "go.uber.org/zap/zapcore" ) type log struct { occurredAt time.Time source string duration time.Duration sql string values []string other []string } func (l *log) toZapFields() []zapcore.Field { return ...
package funcmod // IterChan return a iterable for channel // NOTE: channle could be blocking func IterChan(ch <-chan interface{}) Iterable { return iterable(ch) }
package runtime import ( "fmt" "github.com/healthy-tiger/scalc/parser" ) // 共通のランタイムエラーIDの定義 var ( ErrorTheNumberOfArgumentsDoesNotMatch int ErrorUndefinedSymbol int ErrorAnEmptyListIsNotAllowed int ErrorThe...
package main import ( "context" "log" "time" firebase "firebase.google.com/go" "google.golang.org/api/option" msgbroker "audiman/gu-project/recharger-ser/messageBroker" "audiman/gu-project/recharger-ser/services" ) func main() { mb := setupRabbitMQ() rs := services.NewRechargerService(mb) go rs.InitRecha...
package api import ( "coding-challenge-go/pkg/api/product" "coding-challenge-go/pkg/api/seller" "database/sql" "github.com/gin-gonic/gin" ) // CreateAPIEngine creates engine instance that serves API endpoints, // consider it as a router for incoming requests. func CreateAPIEngine(db *sql.DB) (*gin.Engine, error) ...
package main import "fmt" func A() { defer fmt.Println("Hello from A!") // defer B() fmt.Println("Exiting A...") // } func B() { defer fmt.Println("Hello from B!") // defer A() fmt.Println("Exiting B...") // } func main() { defer B() }
package routers import ( "github.com/astaxie/beego" "homework/backend/controllers" "homework/common/mysql" "homework/common/redis" "homework/models/repositories" "homework/models/services" ) func init() { db, err := mysql.NewMysqlConn() if err != nil { return } conn := redis.NewRedisConn() /* /order ...
/* Copyright 2019 Google 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 law or agreed to in w...
// 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 main import ( "context" "fmt" "io" "os" "strings" "mvdan.cc/sh/interp" "mvdan.cc/sh/syntax" ) func main() { ctx := context.Background() if err := Main(ctx, os.Args, os.Stdin, os.Stdout, os.Stderr); err != nil { switch e2 := err.(type) { case ErrChildExit: fmt.Fprintf(os.Stderr, "smsh: %s\n", ...