text
stringlengths
11
4.05M
// 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 hwsec /* This file implements the TPM clear tool in remote tast. */ import ( "context" "path/filepath" "time" "chromiumos/tast/common/hwsec" "chromiumos/tast/...
package main import ( "fmt" ) type Person struct { Name, Gender string } // 函数内部操作的修改的是传入变量的值拷贝 func f1(p Person) { p.Gender = "female" } // 传递指针可以直接修改传入变量的值 func f2(p *Person) { //语法糖 //标准写法 (*p).Gender="female" p.Gender = "female" } func main() { p := Person{"tom", "male"} f1(p) fmt.Println("p=", p) ...
package main import ( "github.com/spf13/cobra" "github.com/sp0x/torrentd/indexer" "github.com/sp0x/torrentd/torrent" ) func init() { cmdFetchTorrents := &cobra.Command{ Use: "fetch", Short: "Fetches torrents. If no flags are given this command simply fetches the latest 10 pages of torrents.", Run: fetc...
// Copyright © 2018 NAME HERE <EMAIL ADDRESS> // // 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 main import ( "testing" ) func TestCode(t *testing.T) { var tests = []struct { grid []string output []string }{ { grid: []string{"1112", "1912", "1892", "1234"}, output: []string{"1112", "1X12", "18X2", "1234"}, }, { grid: []string{"12", "12"}, output: []string{"12", "12"}, },...
package chance import ( "bytes" ) // String returns random string with length in range [1..100] func (chance *Chance) String() string { var buffer bytes.Buffer l := chance.NaturalN(100) for i := 0; i < l; i++ { buffer.WriteString(string(chance.Char())) } return buffer.String() } // String returns random stri...
package support import "gopkg.in/go-playground/validator.v9" var G_validate *validator.Validate func InitValidator() { G_validate = validator.New() }
package main import "fmt" func main() { // client side data income := 1000 loanAmount := 1000 loanTerm := 24 // bank side data creditScore := 500 // by default, should be changed if there some violation to be approved approved := true // ToDo: implement it in the function ... var monthlyPayment, rate, tota...
package solutions import ( "sort" ) func merge(intervals [][]int) [][]int { var result [][]int sort.Slice(intervals, func(i, j int) bool { return intervals[i][0] < intervals[j][0] }) for i, interval := range intervals { if i == 0 { result = append(result, interval) ...
// 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 e var MsgFlags = map[int]string{ SUCCESS: "ok", ERROR: "fail", ErrInvalidParams: "请求参数错误", ErrUnKnownInternalError: "未知服务器内部错误,请稍后重试", ErrInvalidBasicAuthParam: "Basic认证参数错误", ErrBasicAuthFailed: "未通过Basic认证", ErrUnAuthorized: "你没有权限进行这个操作", Err...
package adservertargeting const ( reqValid = `{ "id": "req_id", "imp": [ { "id": "test_imp1", "ext": {"appnexus": {"placementId": 250419771}}, "banner": {"format": [{"h": 250, "w": 300}]} }, { "id": "test_imp2", "ext": {"appnexus": {"placementId": 250419771}}, "bann...
package main import "fmt" func main() { fmt.Println("洞窟の入口だ。東に進む道もある。") var command = "go inside" switch command { case "go east": fmt.Println("君は、更に山に登る。") case "enter cave", "go inside": fmt.Println("君は薄暗い洞窟の中にいる。") case "read sign": fmt.Println("「未成年立ち入り禁止」と書いてある。") default: fmt.Println("なんだか、よくわから...
package main import "fmt" func main() { const idioma = "Español" name, lastname := "Heriberto", "Figueroa" fmt.Println(name, lastname) name, edad := "Maaria", 20 fmt.Println(name, lastname, edad, idioma) } //TIPICOS COMENTARIOS /* TIPICOS COMENTARIOS */
// Copyright 2020 The LUCI 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...
package engine // Deal adds n cards to each player's hand func Deal(deck Shifter, players []Player, n int) { for j := 0; j < n; j++ { for i := 0; i < len(players); i++ { // Get player to deal to player := players[i] // Get this player's hand hand := player.Hand() // Remove card to deal from top of ...
// 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 import "sort" //332. 重新安排行程 //给定一个机票的字符串二维数组 [from, to],子数组中的两个成员分别表示飞机出发和降落的机场地点,对该行程进行重新规划排序。所有这些机票都属于一个从 JFK(肯尼迪国际机场)出发的先生,所以该行程必须从 JFK 开始。 // //说明: // //如果存在多种有效的行程,你可以按字符自然排序返回最小的行程组合。例如,行程 ["JFK", "LGA"] 与 ["JFK", "LGB"] 相比就更小,排序更靠前 //所有的机场都用三个大写字母表示(机场代码)。 //假定所有机票至少存在一种合理的行程。 //示例 1: // //输入: [["...
package main import ( "fmt" "io/ioutil" "os" "os/exec" "strings" "testing" ) func TestCC(t *testing.T) { files, err := ioutil.ReadDir("test") if err != nil { t.Fatal(err) } for _, finf := range files { if finf.IsDir() { continue } if !strings.HasSuffix(finf.Name(), ".c") { continue } tpath...
package main import "fmt" type human struct { firstname, secondname string } func main() { var people []human firstHuman :=human{ firstname: "Petr", secondname: "Jahoda", } secondHuman :=human{ firstname: "Michal", secondname: "Hovorka", } people = append(people, firstHuman) people = append(people,...
package entity import "fmt" type Edges []Edge func (n Edges) Exist(id string) bool { for _, v := range n { if v.Data.Id == id { return true } } return false } type Edge struct { Data struct { Id string `json:"id"` Source string `json:"source"` Target string `json:"target"` Label string `json...
package main import ( "io" "net/http" ) func d(res http.ResponseWriter, req *http.Request) { io.WriteString(res, "This si my route one") } func c(res http.ResponseWriter, req *http.Request) { io.WriteString(res, "This si my route two") } func main() { http.HandleFunc("/dog", d) http.HandleFunc("/cat", c) /...
// 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 model import "time" // Message is a model for messages. type Message struct { ID uint `gorm:"column:id" json:"id"` CreateTime time.Time `gorm:"column:time" json:"time"` Body string `gorm:"column:body" json:"body"` // Foreign keys SenderID uint `gorm:"column:s...
package operations // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command import ( "time" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/swag" strfmt "...
package main //139. 单词拆分 //给定一个非空字符串 s 和一个包含非空单词列表的字典 wordDict,判定s 是否可以被空格拆分为一个或多个在字典中出现的单词。 // //说明: // //拆分时可以重复使用字典中的单词。 //你可以假设字典中没有重复的单词。 //示例 1: // //输入: s = "leetcode", wordDict = ["leet", "code"] //输出: true //解释: 返回 true 因为 "leetcode" 可以被拆分成 "leet code"。 //示例 2: // //输入: s = "applepenapple", wordDict = ["apple...
/* * Copyright 2019 Nalej * * 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 wri...
package main import ( "context" "fmt" "time" "github.com/kasworld/h4o/appbase" "github.com/kasworld/h4o/appbase/appwindow" "github.com/kasworld/h4o/camera" "github.com/kasworld/h4o/eventtype" "github.com/kasworld/h4o/gls" "github.com/kasworld/h4o/gui" "github.com/kasworld/h4o/light" "github.com/kasworld/h4...
package main import "fmt" type Cat struct { Color string Name string } type BlackCat struct { Cat // 嵌入Cat, 类似于派生 sex string } // “构造基类” func NewCat(name string) *Cat { fmt.Println("===================================") return &Cat{ Name: name, } } // “构造子类” func NewBlackCat(color string...
package main import ( "net/http" ) func main() { mux := http.NewServeMux() mux.HandleFunc("/go/lalala", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("ola mundo go lalala\n\n")) }) mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("ola mundo\n\n")) }) mux.Han...
package configs const ( ProjectName = "gsp2md" )
package get import ( "context" "github.com/shiv3/slackube/app/adapter/slacksender" "github.com/shiv3/slackube/app/view/slack/common" "github.com/slack-go/slack/slackevents" "github.com/slack-go/slack" ) func (h GetHandler) GetNs(ctx context.Context, ev *slackevents.AppMentionEvent) error { res, err := h.usec...
package string import ( "fmt" "github.com/project-flogo/core/data" "github.com/project-flogo/core/data/coerce" "github.com/project-flogo/core/data/expression/function" ) func init() { _ = function.Register(&fnEquals{}) } type fnEquals struct { } func (fnEquals) Name() string { return "equals" } func (fnEqual...
package eventloop import ( "log" "runtime" "sync" ) type InitFunc func(loop *EventLoop) type Worker struct { initFunc InitFunc loop *EventLoop done sync.WaitGroup } func NewWorker(initFunc InitFunc) *Worker { worker := &Worker{ loop: NewEventLoop(), initFunc: initFunc, } worker.done.Add(1) go...
package main import ( "encoding/json" "fmt" "io/ioutil" "log" "os" "github.com/codegangsta/cli" ) const ( // ERROR Codes e1000 = "ERROR[1000]\tunable to load config file " e1010 = "ERROR[1010]\tunable to parse config file " ) type ( // Conf is the configuration for the server's dynamic settings Conf stru...
package server import ( "bytes" "encoding/binary" "fmt" "io" "log" "net" "sync" "time" ) func NewKannaTcpConnection(server *KannaServer, ID int, conn *net.TCPConn, handler MsgHandler) *KannaTCPConnection { c := &KannaTCPConnection{ sKannaConnection: &sKannaConnection{ Server: server, ID: ...
package stringutil import "github.com/golang/example/stringutil" func Reverse(s string) string { return stringutil.Reverse(s) }
/* * @lc app=leetcode.cn id=769 lang=golang * * [769] 最多能完成排序的块 */ package leetcode // @lc code=start func maxChunksToSorted(arr []int) int { max := func (a int, b int) int { if a > b { return a } else { return b } } res, m := 0, 0 for i, v := range arr { m = max(v, m) if m ...
package commands import ( "bufio" "bytes" "fmt" "io" "io/ioutil" "net/http" "net/url" "os" "os/exec" "path/filepath" "strings" build "github.com/Azure/acr-builder/pkg" "github.com/Azure/acr-builder/pkg/constants" dockerbuild "github.com/docker/cli/cli/command/image/build" "github.com/docker/docker/buil...
/* Copyright 2019 The Ceph-CSI 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, so...
package importer import ( "encoding/json" "errors" "github.com/rs/zerolog/log" "io/ioutil" "magicTGArchive/internal/pkg/mongodb" "net/http" "strconv" ) /* RequestAllCards receives a response with type *http.Response from the mtg api containing 100 cards. Returning the response and an error */ func RequestAllCa...
package leetcode import ( "testing" "github.com/go-playground/assert/v2" ) func TestLongestCommonPrefix(t *testing.T) { data := []map[string]interface{}{ { "test": []string{"flower", "flow", "flight"}, "except": "fl", }, { "test": []string{"summer", "summ", "summmmmmmmmmm"}, "except": "summ"...
/* Copyright 2023 Gravitational, 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 writing, softwar...
package sort import "testing" func TestFindKBigNum(t *testing.T) { var arr []int var knum int arr = []int{1} knum = findKBigNum(arr, len(arr), 1) t.Logf("arr: %v, knum: %d", arr, knum) arr = []int{2, 1} knum = findKBigNum(arr, len(arr), 2) t.Logf("arr: %v, knum: %d", arr, knum) arr = []int{3, 1, 2} knum ...
//go:build !windows // +build !windows /* Copyright 2019 The Skaffold 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 app...
package handle import ( . "base" ) type C10000Up struct { SID string //String, } func f10000Up(c uint16, p *Pack, u *Player) []byte { s := new(C10000Up) s.SID = p.ReadString() res := new(C10000Down) //业务逻辑: AddPlayer(s.SID, u) res.Flag = 1 return res.ToBytes() }
package main import ( filepc "protos" "context" "fmt" "google.golang.org/grpc" "net/http" "os" "strings" ) var ( serverAddr = "127.0.0.1:8082" ) func parseRequest(r http.Request, prefix string) map[string]string { request := r.URL.Path[len(prefix):] tokens := strings.Split(request, "&") result := make(map[s...
package blade import ( "bytes" "sort" ) const defaultMaxCacheSize = 8192 type radixChild struct { c byte node *RadixNode } // radixValue is used to avoid the type radixValue struct { k []byte v interface{} } // RadixNode is the note in radix tree. type RadixNode struct { prefix []byte childs []*radixChi...
package Monotone_Increasing_Digits import "testing" func Test_monotoneIncreasingDigits(t *testing.T) { type args struct { N int } tests := []struct { name string args args want int }{ // TODO: Add test cases. { "case", args{ 114191537, }, 113999999, }, { "case", args{ 432...
package Controller import ( "1/Model" "github.com/gin-gonic/gin" ) //点赞 //func Like(c *gin.Context) { // vid := c.Query("vid") // // uid, err := c.Request.Cookie("uid");if err!=nil{ // c.JSON(400,err) // return // } // // if !Model.Like(uid.Value,vid){ // c.JSON(400,"已点赞") // } //} //投币 func Coin(c *gin.Context...
package iteration import "strings" func Repeat(character string, count int) string { return strings.Repeat(character, count) }
// SPDX-License-Identifier: ISC // Copyright (c) 2014-2020 Bitmark Inc. // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package storage import ( "encoding/binary" "fmt" "reflect" "sync" "github.com/syndtr/goleveldb/leveldb" ldb_opt "github.com/syndtr/goleveldb...
package entry import ( "shared/utility/coordinate" "testing" ) func TestYggdrasilEntry_Reload(t *testing.T) { position1 := *coordinate.NewPosition(1, 1) position2 := *coordinate.NewPosition(1, 1) t.Log(position1 == position2) } func TestYggdrasilEntry_GetPosAreaId(t *testing.T) { areaId, err := CSV.Yggdrasil....
package cmd import ( "fmt" "net/url" "regexp" "github.com/manifoldco/promptui" "github.com/redhat-openshift-ecosystem/openshift-preflight/certification/errors" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) const ( baseURL = "https://connect.redhat.com/support/technology-partner/#/c...
// package hash implements various hashing algorithms used in bitcoin package hash
package main import ( "fmt" "log" "math" "net" "github.com/ev3go/ev3dev" "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/reflection" pb "penbot/shared" ) const ( Left = 1 Right = -1 ) type Config struct { A float64 L float64 R float64 } func find_angle(p *pb.Point, l floa...
package config type WeWork struct { CorpID string `yaml:"corp_id"` Agents []*Agent `yaml:"agents"` } func (w *WeWork) GetAgent(id int) *Agent { for _, a := range w.Agents { if a.ID == id { return a } } return nil } type Agent struct { ID int `yaml:"id"` Name string `yaml:"name"` Secret str...
package telepathy import ( "context" "fmt" "net/http" "strings" "testing" "github.com/stretchr/testify/assert" ) func TestRegisterWebhook(t *testing.T) { assert := assert.New(t) server, err := newWebServer("http://localhost", "8080") assert.NoError(err) handler := func(http.ResponseWriter, *http.Request) ...
package cine import "container/list" type MessageQueue struct { queue *list.List limit int In chan *ActorCall Out chan *ActorCall Stop chan bool } func NewMessageQueue(limit int) *MessageQueue { q := new(MessageQueue) q.queue = list.New() q.limit = limit q.In = make(chan *ActorCall) q.Out = make(chan...
// +build !linux package cgroup import ( "github.com/lavaorg/telex" ) func (g *CGroup) Gather(acc telex.Accumulator) error { return nil }
package ipspeicher import ( "errors" "github.com/DATA-DOG/go-sqlmock" "testing" ) /* func (ips *Speicher) getNeuste(name string) (Eintrag, error) { row := ips.Db.QueryRow("SELECT * FROM ips WHERE name = ? ORDER BY seit DESC LIMIT 1", name) return SqlEintrag(row) } func (ips *Speicher) istGespeichert(e Eintrag) ...
package qcloud import ( "fmt" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/multicloud" ) type SElasticcacheParameters struct { multicloud.SElasticcacheParameterBase multicloud.QcloudTags cacheDB *SElasticcache InstanceEnumParam []SElasticcacheParameter `json:"InstanceEnumParam"` ...
package main import "fmt" // Crawl uses fetcher to recursively crawl // pages starting with url, to a maximum of depth. func Crawl(url string, depth int, fetcher Fetcher) { totalurl := []string{url} cururl := []string{url} insertUrl := func(iurl string) { for t, turl := range totalurl { if turl == iurl { ...
package client import "fmt" type ResponseError struct { Err error StatusCode int } func (r *ResponseError) Error() string { return fmt.Sprintf("status %d: err %v", r.StatusCode, r.Err) }
package telegram import ( "crypto/sha1" "encoding/hex" "fmt" "log" "strconv" "time" "github.com/c0re100/RadioBot/config" "github.com/c0re100/RadioBot/fb2k" "github.com/c0re100/RadioBot/utils" "github.com/c0re100/go-tdlib" ) type groupStatus struct { chatID int64 msgID int64 vcID int...
package main import "fmt" func main() { fmt.Println("") var ( prev = [...]string{"The Wolf Hall", "Circee", "The Body Mass"} ) books := prev for i := range prev { books[i] = prev[i] + " 2nd Ed." } fmt.Printf("prevBooks: %#v\n", prev) fmt.Printf("books: %#v\n", books) }
package main import ( "bufio" "fmt" "os" ) var writer = bufio.NewWriter(os.Stdout) var reader = bufio.NewReader(os.Stdin) func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) } func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) } var endOfWorldNums = make([]int, 10004) func ...
package gomo import "testing" func TestImplicitCredentials(t *testing.T) { creds := implicitCredentials{} if creds.grantType() != implicitGrantType { t.Error("Incorrect grant type") } }
package models import ( "../utils" ) type Link struct { Id uint `json:"id"` Url string `json:"url"` Desc string `json:"desc"` Title string `json:"title"` Avatar string `json:"avatar"` } func GetFriendLinks() ([]Link) { data := []Link{} // 从数据库中取回数据 rows, err := db.Query("SELECT `...
// Copyright 2016 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...
// 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 policy import ( "context" "time" "chromiumos/tast/common/fixture" "chromiumos/tast/common/pci" "chromiumos/tast/common/policy" "chromiumos/tast/common/policy/...
package commander // The following are ACTION functions, chose one if you like it. type ( Action func(c Context) _Result // default internal function ActionResult func() _Result ActionNormal func(c Context) error ActionSimple func(c Context) ActionNative func() ActionNativeSim...
// Copyright (C) 2017 Michał Matczuk // Use of this source code is governed by an AGPL-style // license that can be found in the LICENSE file. package server import ( "context" "encoding/json" "errors" "fmt" "io" "net" "net/http" "strconv" "strings" "time" tunnel "github.com/NodeFactoryIo/vedran/pkg/http-...
package lib import ( "testing" "github.com/muesli/termenv" "github.com/stretchr/testify/require" ) func TestPad(t *testing.T) { s := termenv.String("gh").Foreground(profile.Convert(termenv.ANSIYellow)).String() require.Equal(t, s+" ", RPad(s, 4)) } func TestOverlayDraw(t *testing.T) { var o Overlay require...
func isAnagram(s string, t string) bool { if len(s) != len(t) { return false } arr := make([]int, 26) for _, ch := range []rune(s) { arr[ch - 'a']++ } for _, ch := range []rune(t) { if arr[ch - 'a'] == 0 { return false } ...
package verification import ( "bytes" "errors" "io/ioutil" "net" "net/http" "reflect" "testing" "time" "github.com/fabric8-services/fabric8-common/log" "github.com/fabric8-services/fabric8-webhook/util" "github.com/goadesign/goa" goalogrus "github.com/goadesign/goa/logging/logrus" ) var gs *goa.Service ...
package http import ( "marketplace/transactions/domain" "marketplace/transactions/internal/request" "marketplace/transactions/internal/usecase" "net/http" "github.com/gin-gonic/gin" "github.com/go-pg/pg/v10" "github.com/sirupsen/logrus" ) func CreateTransactionHandler(db *pg.DB, cmd usecase.CreateTransactionC...
// +build linux,!legacy_appindicator //go:build linux && !legacy_appindicator package systray /* #cgo linux pkg-config: ayatana-appindicator3-0.1 #include "systray.h" */ import "C"
package main func main() { for i := 0; i <= 150; i++ { if (i%7) == 0 && (i%11) == 0 { println("Múltiplo de 7 e 11") } else if (i % 7) == 0 { println("Múltiplo de 7") } else if (i % 11) == 0 { println("Múltiplo de 11") } else { println(i) } } }
package api import ( "crypto/tls" "encoding/json" "errors" "fmt" "net/http" "sort" "time" "github.com/gorilla/mux" "github.com/hashicorp/go-multierror" "github.com/mlowicki/rhythm/api/auth" "github.com/mlowicki/rhythm/api/auth/gitlab" "github.com/mlowicki/rhythm/api/auth/ldap" "github.com/mlowicki/rhythm...
package pork import ( "testing" "github.com/mspaulding06/nap" ) func TestGetRepositoryReadme(t *testing.T) { token := "49117eb33240d82724587351e54434122667b3f9" GitHubAPI().SetAuth(nap.NewAuthToken(token)) if err := GetRepositoryReadme("mspaulding06/testrepo"); err != nil { t.Fail() } }
package structs import ( "fmt" "go/types" "sort" "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis/passes/buildssa" ssaPkg "golang.org/x/tools/go/ssa" ) var Analyzer = &analysis.Analyzer{ Name: "structs", Doc: Doc, Run: run, Requires: []*analysis.Analyzer{ buildssa.Analyzer, }, } const...
package version var ( Name = "motionctrl" Number = "0.0.13" )
package cursor import ( "testing" ) func TestCursor(t *testing.T) { var b = []byte("select * from stu") // spawn a new Cursor var c = NewCursor(b,0) if c.Index != 0 { t.Errorf("Next() skipped Index 0") } c.Next() if c.Index != 1 { t.Errorf("Next() failed to Increment") } c.SetByte(byte('!')) if c.G...
package main import ( "fmt" "runtime" "sync" "time" ) /** go 线程调度 */ var gw sync.WaitGroup func a() { for i := 0;i<10;i++ { fmt.Println("A:",i) gw.Done() time.Sleep(1000*time.Millisecond) } } func b() { for i := 0;i<10;i++ { fmt.Println("B:",i) gw.Done() time.Sleep(1000*time.Millisecond) } } ...
package dynamic import ( "github.com/jinzhu/now" "logic" "time" ) const ( WeekCycleSeconds = 60 * 60 * 24 * 7 MonthCycleSeconds = 60 * 60 * 24 * 30 ) func (r *Record) SetExpire(a *logic.Activity, nowTime time.Time) { switch r.Type { case FreqType_FreqPerDay: r.Expire = int32(now.New(nowTime).EndOfDay().Uni...
package model import ( "context" "time" "guild/manager" "shared/common" "shared/csv/static" "shared/global" "shared/protobuf/pb" "shared/utility/errors" "shared/utility/glog" "shared/utility/mysql" ) const ( GuildJoinModelAuto = 0 // 公会自由加入 GuildJoinModelHandle = 1 // 公会加入需要审批 GuildChatJoin = 1 // 公会...
package mongo import ( "gopkg.in/mgo.v2" ) var session *mgo.Session func Connect(server string) (err error) { session, err = mgo.Dial(server) return } func NewDb(databaseName string) *mgo.Database { newSession := session.Copy() db := newSession.DB(databaseName) return db }
package service import ( "errors" "github.com/astaxie/beego" "github.com/astaxie/beego/validation" "net/http" "strconv" "tripod/convert" "webserver/common" "webserver/controllers" "webserver/models" "webserver/models/maccount" "webserver/models/mservice" ) type OrderListController struct { controllers.Bas...
// 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 main import ( "io/ioutil" "github.com/rs/zerolog/log" "gopkg.in/yaml.v3" ) type Config struct { Transport []*ConfigTransport `yaml:"Transport"` } type ConfigTransport struct { Addr string `yaml:"Addr"` TargetHost string `yaml:"TargetHost"` TargetPort int `yaml:"TargetPort"` UsePool bool...
package main import ( "net" "time" ) type ( Settings struct { ID int Services []string NumOfSecCheck int64 NumOfSecWait int64 NumOfAttempts int } SettingsChanged struct { Settings Date time.Time } SettingsLoader interface { Start() Close() } settingsLoader struct { rou...
//go:build !windows // +build !windows package nvim // BinaryName is the name of default nvim binary name. const BinaryName = "nvim"
package main import "fmt" func fibo(x int) int { if x == 0 {return x} else if x == 1{return 1}else {return fibo(x-1) + fibo (x-2)} } func main() { fmt.Println("Enter the number:") var x int fmt.Scan(&x) fmt.Println(fibo(x)) }
package jsonrpc import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "testing" ) func TestTransactions_Info(t *testing.T) { c, err := newTestClient() require.NoError(t, err) res, err := c.Transactions.Info("db1aa687737858cc9199bfa336f9b1c035915c30aaee60b1e0f8afadfdb946bd") assert...
package main import "testing" type ProfitCase struct { prices Prices expectedProfit int } func TestMaxProfitCalculation(t *testing.T) { cases := []ProfitCase{{ []int{10, 7, 5, 8, 11, 9}, 6, }, { []int{5, 5, 5, 5, 5, 5, 5, 5}, 0, }, { []int{10, 9, 8, 7, 3, 1}, -1, }, { []int{50, 50, 100, 4...
package netcat import ( "fmt" "log" "net" ) /* Функция StartUDPClient(): 1) Присоединяется к порту; 2) Присоединяется к удалённому серверу UDP; 3) В бесконечном цикле предаёт сообщения, набранные пользователем в консоли: 3.1. Сканирует сообщение пользователя fmt.Scanln; 3.2. Отправляет сообщения пользовате...
// 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 main import "fmt" type messageType int const ( INFO messageType = 0 + iota WARNING ERROR ) const ( InfoColor = "\033[1;34m%s\003[0m" WarningColor = "\033[1;33m%s\003[0m" ErrorColor = "\033[1;31m%s\003[0m" ) func main() { showMessage(INFO, "Hello! This works") } func showMessage(messageType mes...
package money import ( "fmt" "reflect" ) // Money 통화를 나타낸다. type Money struct { amount int currency string } // Dollar USD 통화를 나타낸다. func Dollar(amount int) Money { return Money{amount, "USD"} } // Won KRW 통화를 나타낸다. func Won(amount int) Money { return Money{amount, "KRW"} } // Construct Dollar 생성자 func Con...