text
stringlengths
11
4.05M
package models import( "encoding/json" ) /** * Type definition for EnvironmentsEnum enum */ type EnvironmentsEnum int /** * Value collection for EnvironmentsEnum enum */ const ( Environments_KVMWARE EnvironmentsEnum = 1 + iota Environments_KHYPERV Environments_KSQL Environme...
package main import "fmt" func generate(numRows int) [][]int { switch numRows { case 0: return [][]int{} case 1: return [][]int{{1}} case 2: return [][]int{{1}, {1, 1}} } ret := [][]int{{1}, {1, 1}} for k := 3; k <= numRows; k++ { tmp := make([]int, k) ret = append(ret, tmp) ret[k-1][0], ret[k-1]...
package main import ( "database/sql" "log" "os" "github.com/tupkung/go-todo-service/pkg/models" "github.com/tupkung/go-todo-service/server" _ "github.com/go-sql-driver/mysql" ) var ( todoServiceAddr = os.Getenv("TODO_SERVICE_ADDR") todoServiceCertFile = os.Getenv("TODO_SERVICE_CERT_FILE") todoServiceKe...
package workload import ( "crypto/md5" "encoding/hex" "fmt" "math" "math/rand" "strconv" "sync" "time" "github.com/pavel-paulau/gateload/api" ) type User struct { SeqId int Type, Name, Channel string } const ChannelQuota = 40 func UserIterator(NumPullers, NumPushers int) <-chan User { num...
package routes import ( "log" "net/http" "regexp" "strconv" "strings" "time" "github.com/jelinden/stock-portfolio/app/db" "github.com/jelinden/stock-portfolio/app/domain" "github.com/jelinden/stock-portfolio/app/util" "github.com/julienschmidt/httprouter" ) func AddStock(w http.ResponseWriter, r *http.Requ...
package main import "fmt" func main() { m := make(map[string]int) m["Juan"] = 28 m["Vale"] = 21 fmt.Println(m) // Recorrer map for i, v := range m { fmt.Printf(i, v) } //Encontrar valores value := m["Jose"] fmt.Println(value) // Verificar que la llave este o no en el diccionario value1, ok := m["J...
package stateful import ( "bytes" "encoding/gob" "fmt" "time" "github.com/agence-webup/backr/manager" "github.com/rs/zerolog/log" bolt "go.etcd.io/bbolt" ) var notificationBucket = []byte("notifications") // NewNotifier returns a notifier maintaining its state using bolt func NewNotifier(db *bolt.DB, config ...
/* Copyright SecureKey Technologies Inc. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ package chaincode import ( "encoding/json" "fmt" "sync/atomic" "time" "github.com/hyperledger/fabric-sdk-go/api/apifabclient" "github.com/hyperledger/fabric-sdk-go/api/apitxn" "github.com/hyperledger/fabric-s...
package src var CHANNELTABLE = make(map[string]string) func init() { CHANNELTABLE["name"] = "channel_name" CHANNELTABLE["rank"] = "channel_rank" CHANNELTABLE["view"] = "channel_views_count" CHANNELTABLE["videos"] = "channel_videos_count" }
package main import ( "fmt" "log" "os/exec" "runtime" ) func main() { cmd := exec.Command("ls", "-lah") if runtime.GOOS == "windows" { cmd = exec.Command("tasklist") } res, err := cmd.Output() if err != nil { log.Fatalf("cmd.Output() failed with %s\n", err) } fmt.Println(res) fmt.Println(string(res)) ...
package validations import ( "fmt" "github.com/lestrrat/go-jsschema" ) type MinItemsValidation struct { MinItems int } func NewMinItemsValidation(s *schema.Schema) (MinItemsValidation, error) { if !s.MinItems.Initialized { return MinItemsValidation{}, fmt.Errorf("not initialized") } return MinItemsValidatio...
package main //321. 拼接最大数 //给定长度分别为m和n的两个数组,其元素由0-9构成,表示两个自然数各位上的数字。现在从这两个数组中选出 k (k <= m + n)个数字拼接成一个新的数,要求从同一个数组中取出的数字保持其在原数组中的相对顺序。 // //求满足该条件的最大数。结果返回一个表示该最大数的长度为k的数组。 // //说明: 请尽可能地优化你算法的时间和空间复杂度。 // //示例1: // //输入: //nums1 = [3, 4, 6, 5] //nums2 = [9, 1, 2, 5, 8, 3] //k = 5 //输出: //[9, 8, 6, 5, 3] //单调栈 func ...
// Copyright 2019 - 2022 The Samply Community // // 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 ...
package epb import "testing" func TestEnergyClass(t *testing.T) { testCases := []struct { reg Regulator cons float64 want string }{ {RegulatorBrussels, 100, "C+"}, {RegulatorWallonia, 200, "C"}, } for _, tc := range testCases { if got := EnergyClass(tc.reg, tc.cons); got != tc.want { t.Errorf("%q,...
package main func (___Vuen *_TuEncode) IRun(___Vidx int) { switch ___Vidx { case 1100101: if nil == ___Vuen.enCB1100101init { _FuEncode__1100101__main_init__default(___Vuen) } else { ___Vuen.enCB1100101init(___Vuen) } case 1100201: if nil == ___Vuen.enCB1100201chanRece { _FuEncode__1100201x__chanRe...
package antnet import ( "container/heap" ) type item struct { value int // The value of the item; arbitrary. priority int // The priority of the item in the queue. index int // The index of the item in the heap. } type priorityQueue struct { im map[int]int m map[int]*item cf func(l, r *item) bool } fu...
/** 数组可以储存同一类型的数据, 但在结构体中我们可以为不同项定义不同的数据类型. 结构体是由一系列具有相同类型或不同类型的数据构成的数据集合. 结构体表示一项纪录, 比如保存图书馆的数据记录, 每本书有以下属性: Title: 标题 Author: 作者 Subject: 学科 ID: 书籍ID 定义结构体 结构体定义需要使用type和struct语句. struct语句定义一个新的数据类型, 结构体中有一个或多个成员. type语句设定结构体的名称. 机构提的格式如下: type struct_variable_type struct { member definition; member defini...
package app import ( "encoding/json" "fmt" "net/http" "net/http/httptest" "net/url" "os" "strconv" "strings" "testing" "github.com/gin-gonic/gin" "github.com/jmoiron/sqlx" _ "github.com/lib/pq" "github.com/mercedtime/api/db/models" ) func testConfig() *Config { conf := &Config{} conf.Database.Driver =...
package compression import ( "testing" fb "github.com/google/flatbuffers/go" "log" "reflect" ) func TestZLib(t *testing.T) { b := fb.NewBuilder(0) b.StartObject(6) b.PrependFloat32(100.5) b.PrependFloat32(50.6) b.PrependUint32(1) b.PrependByte(1) b.PrependByte(1) b.PrependUint16(14) off := b...
package cfapi import ( "encoding/json" "fmt" "io" "net" "net/http" "net/url" "path" "time" "github.com/google/uuid" "github.com/pkg/errors" ) // Route is a mapping from customer's IP space to a tunnel. // Each route allows the customer to route eyeballs in their corporate network // to certain private IP r...
package jq import ( "encoding/json" "errors" "fmt" "github.com/itchyny/gojq" ) // Query executes a compiled jq query against given input. It expects a single result only. func Query(query *gojq.Query, input []byte) (interface{}, error) { var j interface{} if err := json.Unmarshal(input, &j); err != nil { ret...
package main import ( "fmt" "os" ) func test(str string, args ...int) { println("str=", str) for index, value := range args { fmt.Printf("%d=%d\n", index, value) } } func main() { test("abc", 20, 30, 40) // 接受用户的参数,字符串方式传递 list := os.Args n := len(list) fmt.Println("n=", n) for i := 0; i < n; i++ { ...
package main import "fmt" func main() { ages := map[string]int{ "Максим": 20, "Олег": 24, "Саня": 28, "Антон": 35, } var ages2 map[string]int fmt.Println(ages) fmt.Println(ages2) ages2 = ages delete(ages, "Антон") delete(ages, "Саня") fmt.Println(ages) fmt.Println(ages2) }
/* MIT License Copyright (c) 2020-2021 Kazuhito Suda This file is part of NGSI Go https://github.com/lets-fiware/ngsi-go Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, inc...
package entity type JobSeekerDetails struct { ID int `gorm:"PrimayKey" json:"id"` NoHandphone int `json:"no_handphone"` Gender string `json:"gender"` Address string `json:"address"` Experience string `json:"experience"` Education string `json:"education"` Skills string `json:"ski...
package main // Leetcode 941. (easy) func validMountainArray(A []int) bool { if len(A) <= 2 { return false } i := 0 for i < len(A)-1 { if A[i] >= A[i+1] { break } i++ } if i == 0 || i == len(A)-1 { return false } for i < len(A)-1 { if A[i] <= A[i+1] { break } i++ } return i == len(A)-1...
package internal import ( "encoding/json" "fmt" "testing" ) var testPaths = []string{ "auth/token/lookup-self", "auth/token/renew-self", "auth/token/revoke-self", "cubbyhole/*", "identity/entity/id/{{identity.entity.id}}", "identity/entity/name/{{identity.entity.name}}", "sys/capabilities-self", "sys/contr...
package kata import ( "fmt" ) // Josephus Permutation func Josephus(items []interface{}, k int) []interface{} { res := []interface{}{} index := 0 for len(items) > 0 { fmt.Printf("\nLen : %d", len(items)) elim := k - 1 + index for elim >= len(items) { elim = elim - len(items) } fmt.Printf("\nEliminat...
package main import ( "bufio" "fmt" "os" "strconv" ) func main() { var n int64 scanner := bufio.NewScanner(os.Stdin) if scanner.Scan() { s := scanner.Text() n, _ = strconv.ParseInt(s, 10, 64) } var reach int = 5 var likes int = reach / 2 if n == 1 { fmt.Println(likes) return } likes = recursiv...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package api_test import ( "net/http/httptest" "testing" "time" "github.com/golang/mock/gomock" mocks "github.com/mattermost/mattermost-cloud/internal/mocks/model" "github.com/gorilla/mux" "githu...
package model import ( "github.com/jinzhu/gorm" "github.com/pkg/errors" "mdstest/helper" "encoding/json" "time" ) type UserSetting struct { SettingId int `json:"setting_id" gorm:"primary_key:AUTO_INCREMENT"` UserId string User *User `gorm:"ForeignKey:UserId;AssociationForeignKey:UserId;-"` SettingKe...
package main import ( "time" ) const timeout = time.Second * 2 func main() { // TODO: код писать здесь } func realMain(goroutineDuration time.Duration) error { // TODO: код писать здесь return nil } // TODO: код писать здесь
/* * @lc app=leetcode id=118 lang=golang * * [118] Pascal's Triangle * * https://leetcode.com/problems/pascals-triangle/description/ * * algorithms * Easy (51.68%) * Likes: 1401 * Dislikes: 107 * Total Accepted: 374.1K * Total Submissions: 722.4K * Testcase Example: '5' * * Given a non-negative in...
// Copyright 2017 HootSuite Media 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 in ...
package v1 import ( "context" "encoding/json" "fmt" "net/http" "strings" "github.com/gorilla/mux" v1 "github.com/tmax-cloud/registry-operator/api/v1" "github.com/tmax-cloud/registry-operator/internal/utils" "github.com/tmax-cloud/registry-operator/internal/wrapper" "github.com/tmax-cloud/registry-operator/p...
// Copyright 2015 The Bazel Authors. 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 appl...
package parsehtml import ( "github.com/PuerkitoBio/goquery" "log" "strconv" ) /** */ type UserInfo struct { UserId string /** 用户IDeg."dbfdce352c0d"*/ NickName string /** 用户昵称 eg." 遛遛心情的溜妈"*/ UserUrl string /** 用户主页url eg "https://www.jianshu.com/u/dbfdce352c0d"*/ UserFollowing int /**关注数*/ UserFollower i...
package local import ( "bytes" "context" "fmt" "io/ioutil" "math/rand" "os" "testing" "github.com/grafana/tempo/pkg/io" "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/grafana/tempo/tempodb/backend" ) const objectName = "test" func TestReadWrite(t *testing.T) { tempDir, err :...
//go:build linux // +build linux package launcher import ( "io" "os" "os/exec" "os/user" "strings" "syscall" log "github.com/sirupsen/logrus" "golang.org/x/sys/unix" "github.com/docker-slim/docker-slim/pkg/system" ) // copied from libcontainer func fixStdioPermissions(uid int) error { var null unix.Stat_...
// Copyright 2019 Yunion // // 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 matchmaker import ( "github.com/td0m/cupidbot" ) // SimpleMatcher is the simplest implementation of a match maker type SimpleMatcher struct { } // NewSimpleMatcher creates a new simple match maker func NewSimpleMatcher() *SimpleMatcher { return &SimpleMatcher{} } // Match implementation func (s *SimpleMat...
package fibre import ( "encoding/json" "flag" "fmt" "net/http" "net/http/httptest" "os" "strings" "testing" "github.com/gorilla/mux" ) var ( cwd_arg = flag.String("cwd", "", "set cwd") ) func init() { flag.Parse() if *cwd_arg != "" { if err := os.Chdir(*cwd_arg); err != nil { fmt.Println("Chdir err...
package purchaseorderapi_test import ( "fmt" dolittleK8s "github.com/dolittle/platform-api/pkg/dolittle/k8s" "github.com/dolittle/platform-api/pkg/k8s" "github.com/dolittle/platform-api/pkg/platform" . "github.com/dolittle/platform-api/pkg/platform/microservice/purchaseorderapi" . "github.com/onsi/ginkgo" . "g...
package conf import ( "flag" "fmt" "log" "github.com/chxfantasy/go_bootstrap/persist/mongo" "github.com/chxfantasy/go_bootstrap/persist/redis" "github.com/gin-gonic/gin" "github.com/globalsign/mgo" ) var ( Gin *gin.Engine Redis1 *redis.Pool MongoTest *mgo.Session AppConf *AppConfig Biz...
package main import "github.com/kovetskiy/lorg" const ( masterFormat = `master: ${level:%s\::left:true} ${time} %s` forkFormat = `fork: ${level:%s\::left:true} ${time} %s` ) func getLogger() *lorg.Log { logger := lorg.NewLog() logger.SetLevel(lorg.LevelDebug) return logger }
// Copyright 2014 The Cockroach 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 ag...
// Package main ... package main import ( "log" "strings" "github.com/go-rod/rod" ) // This example demonstrates how to extract text from a specific element. func main() { page := rod.New().MustConnect().MustPage("https://pkg.go.dev/time") res := page.MustElement("#pkg-overview").MustParent().MustText() log....
package nilapp import ( "github.com/anildukkipatty/tmsp/types" ) type NilApplication struct { } func NewNilApplication() *NilApplication { return &NilApplication{} } func (app *NilApplication) Info() string { return "nil" } func (app *NilApplication) SetOption(key string, value string) (log string) { return ""...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package model import ( "testing" "github.com/stretchr/testify/require" ) func TestNewKopsMetadata(t *testing.T) { t.Run("nil payload", func(t *testing.T) { eksMetadata, err := NewEKSMetadata(nil) ...
package optional import ( "errors" "fmt" "reflect" "time" ) type Optional[T any] struct { some *Some none *None fail *Fail empty *Empty } func WithSome[T any](v interface{}) *Optional[T] { var s *Some switch v.(type) { case *Some: s = v.(*Some) break default: s = NewSome(v) } return &Option...
package main import ( "fmt" "os" "sort" "strconv" ) func main() { fmt.Println("") var inputs []int if len(os.Args) < 2 { fmt.Printf("Please input numbers..\n") return } for i := range os.Args { if i == 0 { continue } num, err := strconv.Atoi(os.Args[i]) //fmt.Printf("num...%d\n", num) if err...
package signer import ( mint "github.com/void616/gm.mint" "github.com/void616/gm.mint/internal/ed25519" ) // Signer data type Signer struct { private mint.PrivateKey public mint.PublicKey } // New made from random keypair func New() (*Signer, error) { p, err := mint.NewPrivateKey() if err != n...
package booksretriever import ( "context" "database/sql" "github.com/diegoholiveira/bookstore-sample/books" ) type ( repository struct { db *sql.DB } ) func NewBooksRetrieverRepository(db *sql.DB) BooksFinder { return repository{ db: db, } } func (r repository) FindBookByID(ctx context.Context, id uint6...
package main import ( "fmt" "strconv" "strings" "testing" ) func TestSum(t *testing.T) { testCases := []struct { x int y int z int want int }{ {+1, +1, +1, 3}, {+1, +1, -2, 0}, {-1, -2, -3, -6}, } for _, tc := range testCases { t.Run(fmt.Sprintf("%d+%d+%d", tc.x, tc.y, tc.z), func(t ...
// // DISCLAIMER // // Copyright 2020 ArangoDB GmbH, Cologne, Germany // // 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 require...
// Copyright 2018 The go-Dacchain Authors // This file is part of the go-Dacchain library. // // The go-Dacchain library is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License...
// Copyright (C) 2015-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 th...
package datastructures type directedGraph struct { vertices map[int]Vertex edges map[Edge]Edge } type directedVertex struct { key int sources map[int][]Edge destinations map[int][]Edge } type directedEdge struct { from Vertex to Vertex weight int } //NewDirectedGraph returns a pointer...
package models import ( "math/rand" "github.com/icrowley/fake" "../database" "../myfaker" ) // User - user struct type User struct { Fname string Sname string Patronymic string Pnumber string } // Insert - inserts user in database func (u *User) Insert(db *database.DB) (err error) { if u.Patr...
package ping import ( "github.com/gin-gonic/gin" "net/http" ) // Ping is a function that will be used to test the connectivity to our server func Ping(ctx *gin.Context) { ctx.String(http.StatusOK, "pong") }
package helpers import ( "github.com/LiveSocket/bot/conv" "github.com/LiveSocket/bot/service" "github.com/gammazero/nexus/v3/wamp" ) // UpdateCommand WAMP call helper for updating a command func UpdateCommand(service *service.Service, command *Command) (*Command, error) { dict := wamp.Dict{ "channel": comma...
/* Created on 2018/4/26 16:24 author: ChenJinLong Content: */ package main import ( "math/rand" "time" "fmt" "math" ) type awards [][]int type awardlist [][][]int type awardlists [][][][]int func GetAwardByWeight(awards awards) []int { var weights = 0 for _, award := range awards { weights += award[len(a...
package utils import ( "fmt" "log" ) // Logger defines an interface for logs type Logger interface { // logging facilities Debug(...interface{}) Debugf(string, ...interface{}) Debugw(string, ...interface{}) Error(...interface{}) Errorf(string, ...interface{}) Errorw(string, ...interface{}) Info(...interface...
package main import ( "fmt" "io" "net" "os" ) func handle(err error) { if err != nil { fmt.Fprintf(os.Stderr, "%w", err) } } func main() { if len(os.Args) != 2 { fmt.Printf("usage: netcat \"addr:port\"\n") } conn, err := net.Dial("tcp", os.Args[1]) handle(err) done := make(chan struct{}) go func() {...
// 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 sophos import ( "context" "strings" multiav "github.com/saferwall/saferwall/internal/multiav" "github.com/saferwall/saferwall/internal/utils" ) ...
// 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, ...
// Copyright (c) 2016-2019 Uber Technologies, 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...
package main func sum(a float32, b float32) float32 { return a + b } func main() {}
package config import ( "encoding/json" "fmt" "mraft/productready/utils" "strconv" "time" "github.com/xkeyideal/gokit/httpkit" ) type DynamicConfig struct { // raft数据存储目录 RaftDir string `json:"raftDir"` // raft最初的集群地址,IP+Port RaftPeers []string `json:"raftPeers"` // 该节点是否是raft的最初集群之一 Native bool `json:...
// Copyright 2021 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 main import ( "github.com/fwchen/jellyfish/application" configs "github.com/fwchen/jellyfish/config" "github.com/fwchen/jellyfish/database" "github.com/fwchen/jellyfish/logger" "github.com/fwchen/jellyfish/service" _ "github.com/labstack/gommon/log" "github.com/opentracing/opentracing-go" "go.elastic.c...
package nginx import ( "context" "encoding/json" "fmt" "strings" "github.com/layer5io/gokit/smi" ) func (h *handler) validateSMIConformance(id string, version string) error { e := &Event{ Operationid: id, Summary: "Deploying", Details: "None", } annotations := map[string]string{ "injector.n...
package indexer import ( "github.com/sp0x/torrentd/indexer/search" "github.com/sp0x/torrentd/indexer/status/models" "github.com/sp0x/torrentd/storage" ) type StandardReportGenerator struct{} //go:generate mockgen -source reportGenerator.go -destination=reportGeneratorMocks.go -package=indexer type ReportGenerator...
package models import "time" // Room stores information about a room type Room struct { ID uint `json:"id" gorm:"primary_key"` Name string `json:"name" gorm:"type:varchar(255)"` ShortName string `json:"short_name" gorm:"type:varchar(255)"` Password string `json:"password"` CreatedA...
/* Copyright The containerd 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...
package main import ( "fmt" "io/ioutil" "log" "math" "strconv" "strings" ) // Day03 represents the answers for the day 3 problem. type Day03 struct { part1 int part2 int } // CartesianCoord represents the cartesian coordinate system. type CartesianCoord struct { x int y int } func main() { content, err :...
package handle import ( "log" "os" "strconv" "github.com/intxiaoquan/vjudge_lab_helper/jsonstruct" "github.com/nguyenthenguyen/docx" ) func DocOn(outData [20]jsonstruct.Output2File, len int) { rr, err := docx.ReadDocxFile("./tmpl.docx") if err != nil { panic(err) } docx1 := rr.Editable() for i := 0; i <...
package elements type SectionProperties struct { SectionType *SectionType // Page Size PgSz *PageSize // Page Margins //PgMar *PageMargin }
package apiService import "net" type dao interface { OpenLock(string) bool AddBadge(string, string, string) bool DeleteBadge(string) bool GetServerAddress() net.IP ChangeMode(string) bool GetCurrentMode() string GetLastLog() string GetBadgesList() []Badge SetNomPrenom(string, string, string) boo...
/* * Created by lintao on 2023/8/1 下午4:04 * Copyright © 2020-2023 LINTAO. All rights reserved. * */ package code //go:generate codegen -type=int //go:generate codegen -type=int -doc -output ./error_code_generated.md // 通用: 基本错误 // Code must start with 1xxxxx. const ( // ErrSuccess - 200: OK. ErrSuccess int = i...
package tips import ( "testing" ) type interfaceX interface { implementX() } type interfaceY interface { implementY() } type interfaceZ interface { interfaceX interfaceY } type impl int func (impl) implementX() {} func (impl) implementY() {} func TestInterfaceEqualityOp(t *testing.T) { // References: // h...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package audio import ( "context" "os" "path/filepath" "strings" "gopkg.in/ini.v1" "chromiumos/tast/errors" "chromiumos/tast/local/crosconfig" ) // BoardConfig repr...
package event_handler import ( "errors" "fmt" cloudevents "github.com/cloudevents/sdk-go/v2" "github.com/keptn/go-utils/pkg/lib/keptn" keptnv2 "github.com/keptn/go-utils/pkg/lib/v0_2_0" "net/http" "net/url" "os" "strconv" ) const ActionToggleFeature = "toggle-feature" type ActionTriggeredHandler struct { L...
package server import ( syllabusModel "mall/app/service/main/exam/model" "mall/lib/net/http" "github.com/gin-gonic/gin" ) func createExamSyllabus(c *gin.Context) { var syllabus syllabusModel.ExamSyllabus if err := c.Bind(&syllabus); err != nil { http.Response(c, 400, "参数错误,"+err.Error(), nil) return } a...
// Copyright (C) 2017 Google 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 t...
package agent import ( "fmt" "log" "net/http" "time" "github.com/spf13/cobra" "github.com/rancher/fleet/pkg/version" command "github.com/rancher/wrangler-cli" ) var ( debugConfig command.DebugConfig ) type FleetAgent struct { Kubeconfig string `usage:"kubeconfig file"` Namespace string `usage...
package tingbill import "github.com/shopspring/decimal" func (b Bill) DeviceIds() []string { deviceIds := make([]string, len(b.Devices)) for i, d := range b.Devices { deviceIds[i] = d.DeviceID } return deviceIds } func (b Bill) OwnerByID(id string) string { o := "Unknown" for _, d := range b.Devices { i...
package repository import "github.com/flaviowilker/rentcar/app/domain" // RoleRepository ... type RoleRepository interface { FindByCode(string) (*domain.Role, error) }
package main import "fmt" /** *设计模式-结构型 *装饰器模式 */ // step1: 编写基础功能,刚开始不需要定义接口 type Base struct { } func (b *Base) Call() string { return "base is called" } // step2: 将上面的方法声明为接口类型,基础功能中的 Call() 调用自动满足下面的接口 type DecoratorI interface { Call() string } // step3: 编写新增功能,结构中保存接口类型的参数 type Decorator struct { deror...
package gotool import( _ "github.com/iyf/gotool/config" _ "github.com/iyf/gotool/database/activerecord" _ "github.com/iyf/gotool/i18n" _ "github.com/iyf/gotool/log" _ "github.com/iyf/gotool/middleware" _ "github.com/iyf/gotool/utils" _ "github.com/iyf/gotool/web" _ "github.com/iyf/gotoo...
package indexer import ( "fmt" "testing" . "github.com/onsi/gomega" "github.com/sp0x/torrentd/indexer/definitions" ) func TestAssetLoader_List(t *testing.T) { g := NewWithT(t) ldr := CreateEmbeddedDefinitionSource([]string{"a", "b", "c.yml"}, func(key string) ([]byte, error) { return nil, nil }) names, er...
package get import ( "encoding/json" "fmt" "net/http" "github.com/ocoscope/face/db" "github.com/ocoscope/face/utils" ) func Users(w http.ResponseWriter, r *http.Request) { type tbody struct { CompanyID, UserID int64 AccessToken string } var body tbody err := json.NewDecoder(r.Body).Decode(&body...
package main import "fmt" func main() { var a int var b int32 a = 15 b = int32(a) + 5 b = b + 5 fmt.Printf("%05d %03d\n", a, b) }
package main import ( "fmt" "net" "testing" "unsafe" ) func foo(a []interface{}) { // fmt.Println(a) fmt.Println(fmt.Sprintf(a[0].(string), a[1:]...)) } func IsLittleEndian() bool { var i uint = 0x01020304 u := unsafe.Pointer(&i) pb := (*byte)(u) b := *pb return (b == 0x04) } type LogConn interface { ne...
package gotojs import ( "bytes" "encoding/base64" "io/ioutil" "testing" ) func TestArrayContains(t *testing.T) { x := [...]string{"a", "b", "c"} if !ContainsS(x[:], "b") { t.Errorf("Positiv contains test failed.") } if ContainsS(x[:], "x") { t.Errorf("Negative contains test failed.") } } func TestAppe...
package models type SsoUserRole struct { Id int64 UserId string RoleId int64 WorkspaceId int64 NamespaceId int64 ClusterId int64 RoleName string } type UserRole struct { RoleId int64 WorkSpaceId int64 NamespaceId int64 ClusterId int64 RoleName string } type GetUserRolesQuery struct { UserId st...
package main import ( "fmt" "math" "os" "time" "unsafe" ) func main() { fmt.Println("print in one line") // base s1 := "" var s2 string var s3 = "" // var s4 string = "123" // have warning var i, j, k = 0, 1, 2 fmt.Println(s1, s2, s3) fmt.Println(i, j, k) var f float64 f = math.Pi fmt.Printf("test ...
package util import "os" // FileExists checks if a file exists // on the local file system func FileExists(path string) bool { if _, err := os.Stat(path); os.IsNotExist(err) { return false } return true }
package main import ( "context" "fmt" "github.com/apache/thrift/lib/go/thrift" "os" "thriftDemo/gen-go/thriftAPI" "time" ) var defaultCtx = context.Background() func handleClient(client *thriftAPI.UserInfoServiceClient) (err error) { userInfo, _err := client.GetUserByName(defaultCtx, "1") if _err==nil{ fmt...
package errors import ( "encoding/json" "testing" "fmt" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tendermint/abci/types" ) func TestErrorCode_MarshalJSON(t *testing.T) { ec := NewErrorCode(ErrorCodeDataStackOverflow) bs, err := json.Marshal(ec) require.NoError(t...