text
stringlengths
11
4.05M
// Copyright 2017 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 data // // Copyright (c) 2019 ARM Limited. // // SPDX-License-Identifier: MIT // // 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, including without limit...
package cmd import ( "bytes" "context" "encoding/json" "log" "os/exec" "regexp" "strconv" "strings" "time" "github.com/gabrielperezs/goreactor/lib" "github.com/gabrielperezs/goreactor/reactor" "github.com/gabrielperezs/goreactor/reactorlog" "github.com/savaki/jq" ) const ( defaultMaximumCmdTimeLive = 1...
package problem0022 import "strings" func generateParenthesis(n int) []string { res := []string{} p := "" var dfs func(string, int, int, int) dfs = func(p string, n int, l int, r int) { if l == n { res = append(res, p+strings.Repeat(")", l-r)) return } if l < n { dfs(p+"(", n, l+1, r) } if r ...
// 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" "regexp" "time" "github.com/golang/protobuf/ptypes/empty" "chromiumos/tast/common/servo" "chromiumos/tast/ctxutil" "chromiumos/t...
package base // Track : represents a track type Track struct { Name string `json:"name"` } // Playlist : represents a playlist type Playlist []Track // Genre : type definition to represents a playlist genre type Genre string // Genre's avaliables const ( GenreParty Genre = "party" GenrePop Genre = "pop...
package server import ( "net/http" "io" "users" ) func RootHandler(w http.ResponseWriter, req *http.Request) { io.WriteString(w, "Welcome to the Printox alpha API\n") } // SignUpHandler receives a signup request func SignUpHandler(w http.ResponseWriter, req *http.Request) { if parseErr := users.ParseSignUp...
package exporter import ( "encoding/json" "encoding/xml" "errors" "fmt" week3 "go_feed_export" "os" yaml "gopkg.in/yaml.v2" ) // ScrollFeeds prints all social media feeds func ScrollFeeds(platforms ...week3.SocialMedia) { for _, sm := range platforms { for _, fd := range sm.Feed() { fmt.Println(fd) } ...
package md5 import ( "testing" ) func TestComputeFile(t *testing.T) { r, err := ComputeFile("/Volumes/Data/软件/deepin-desktop-community-1002-amd64.iso") if err != nil { t.Error(err.Error()) return } t.Log(r) }
package geojson_test import ( "encoding/json" "fmt" "log" "github.com/paulmach/orb" "github.com/paulmach/orb/geojson" "github.com/paulmach/orb/quadtree" ) func ExampleFeature_Point() { f := geojson.NewFeature(orb.Point{1, 1}) f.Properties["key"] = "value" qt := quadtree.New(f.Geometry.Bound().Pad(1)) err ...
package main import ( "database/sql" "fmt" ) //NewConnection create connection to mariaDB func newConnection(u string, p string, db string, host string, port int) (*sql.DB, error) { //dbSource := u + ":" + p + "@tcp(" + host + ":" + strconv.Itoa(port) + ")/" + db + "?parseTime=true" dbSource := fmt.Spri...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // //+build e2e package pkg import ( "fmt" "time" "github.com/sirupsen/logrus" "github.com/pkg/errors" ) // WaitConfig contains configuration for WaitForFunc. type WaitConfig struct { Timeout ...
// Copyright (C) 2018 Minio 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 ...
package kindle_emailer import ( "fmt" "kindle_clipping_exporter/kindle" "log" "net/smtp" "strings" ) const messageHeader = "To: %s\r\nSubject: Your most recent kindle clippings\r\n" type Credentials struct { FromEmail string FromEmailPassword string ToEmail string } func SendEmail(d kindle...
package cache import ( "sync" "time" ) type CacheItem struct { sync.RWMutex Key interface{} Data interface{} LifeSpan time.Duration TimeStamp time.Time } func CreateCacheItem(cache_key interface{}, cache_data interface{}) *CacheItem { Item := CacheItem{Key: cache_key, Data: cache_data} return &I...
package dialect import ( "context" "time" "github.com/phogolabs/log" ) // Logger represents a logger type Logger = log.Logger // LoggerDriver is a driver that logs all driver operations. type LoggerDriver struct { Driver logger Logger } // Log gets a driver and an optional logging function, and returns // a n...
package main import ( "fmt" "os" "github.com/jessevdk/go-flags" ) const VERSION = "2.0.0-beta5" type Options struct{} var ( options Options cmd = flags.NewParser(&options, flags.Default) ) func main() { cmd.SubcommandsOptional = true _, err := cmd.Parse() if err != nil { os.Exit(1) } if cmd.Comma...
package main import ( "fmt" "time" ) //When using channels as function parameters, as you often will, by default can send and receive within the function. //To provide additional safety at compile time, channel function parameters can be defined with a direction. //That is, they can be defined to be read-only or wr...
package middleware import ( "net/http" "project/packages/authentication/token" "project/packages/handlers/response" ) func UserAuthorize(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { //getToken tokenString, err := token.GetTokenString(r) if err != n...
package main import ( "fmt" "io/ioutil" "regexp" "strings" "strconv" ) type Disc struct { numberOfPositions, currentPosition int } func main() { discs := parseInput("day15input") solve(discs) } func parseInput(filename string) []Disc { var discs []Disc input, err := ioutil.ReadFile(filename) r...
package middleware import ( "github.com/gin-gonic/gin" ) // Common 全局通用的中间件 func Common(r *gin.Engine) { r.Use(gin.Recovery()) r.Use(ErrorMiddleware()) }
package canvas import ( "github.com/gopherjs/gopherjs/js" "github.com/gopherjs/jquery" "github.com/platinasystems/weeb/r2" "fmt" ) type CompositeOperation int const ( SrcOver CompositeOperation = iota // A over B (default) SrcAtop // A atop B SrcIn // A i...
package util import ( "os" "fmt" "bufio" "io" ) type FileReadUtil interface { Read() ([]byte, error) } type BufferFileReader struct { path string } func NewBufferFileReader(path string) FileReadUtil { read := new(BufferFileReader) read.path = path return read } func (reader *BufferFileReader) Read() ([]by...
package devpod import ( "context" "crypto/tls" "fmt" "github.com/loft-sh/devspace/pkg/devspace/kill" "io" "net/http" "os" syncpkg "sync" "github.com/loft-sh/devspace/pkg/devspace/deploy" "github.com/mgutz/ansi" kerrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8...
package store import ( log "git.ronaksoftware.com/blip/server/internal/logger" "git.ronaksoftware.com/blip/server/internal/tools" "git.ronaksoftware.com/blip/server/pkg/config" "github.com/mailru/easyjson/gen" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mo...
package main import ( "fmt" "strconv" "time" ) func sample11(ch chan string) { for i := 0; i < 19; i++ { ch <- "select test" + strconv.Itoa(i) time.Sleep(time.Second * 1) } } func sample112(ch chan int) { for i := 0; i < 19; i++ { ch <- i time.Sleep(time.Second * 2) } } func main() { ch1 := make(ch...
package elastic import ( "github.com/olivere/elastic" "time" "context" ) type Eser interface { Init() error Put(area string,message interface{}) error Index() error } type es struct { client *elastic.Client addr string ctx context.Context index string } //addr http://192.168.2.10:9201 func New(addr,index ...
package apis import ( "fmt" "trueabc.top/zinx/ziface" "trueabc.top/zinx/zinx_app_demo/mmo_game/game_server/core" "trueabc.top/zinx/zinx_app_demo/mmo_game/game_server/pb" "trueabc.top/zinx/znet" ) type MoveApi struct { znet.BaseRouter } func (a *MoveApi) Handler(request ziface.IRequest) { // 解析客户端的协议 proto_ms...
package main import "fmt" var java, python, c bool func main() { var i int fmt.Println(java, python, c, i) }
package ravendb type tcpNegotiateParameters struct { operation operationTypes version int database string sourceNodeTag string destinationNodeTag string destinationUrl string readResponseAndGetVersionCallback func(string) int }
func threeSum(nums []int) [][]int { if len(nums) == 0 { return nil } ans := make([][]int, 0, 1) sort.Ints(nums) for i := 0; i < len(nums); i++ { //dedupulicate num i if i != 0 && nums[i] == nums[i - 1] { continue } l, r := i + 1, len(nums) - 1 ...
package main // Leetcode 1055. (medium) func shortestWay(source string, target string) int { m, n := len(source), len(target) dp := make([][]int, m+1) for i := range dp { dp[i] = make([]int, 26) } for i := 0; i < 26; i++ { dp[m][i] = m } for i := m - 1; i >= 0; i-- { for j := 0; j < 26; j++ { if sourc...
package main import ( "encoding/csv" "fmt" "io" "io/ioutil" "log" "strings" ) var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" var names []string func main() { names = readNamesFile("names.txt") sortNames(0, len(names)-1) sum := 0 for i := range names { sum += score(i) } fmt.Println("sum:", sum) } func sco...
package rpc import ( "bytes" "github.com/davecheney/nfs/xdr" "io" ) type transport interface { send([]byte) error recv() ([]byte, error) io.Closer } type mismatch_info struct { low uint32 high uint32 } type Header struct { Rpcvers uint32 Prog uint32 Vers uint32 Proc uint32 Cred Auth Verf ...
package main import "fmt" // Slices in go or maybe even arrays(Check this), will double the memory allocated if full and you want to `append` to it // NOTE: ^^ in ex4a4b4c.go, the groceryList append function adds to the array BUT the fucntion is pure so I don't know if the statement is true func arraysAndSlices() { ...
package exporter import ( "context" "crypto/md5" "fmt" "log" "os" "os/exec" "regexp" "sort" "strconv" "strings" "github.com/databrickslabs/terraform-provider-databricks/common" "github.com/databrickslabs/terraform-provider-databricks/compute" "github.com/databrickslabs/terraform-provider-databricks/ident...
package main import ( "fmt" "strconv" ) func main() { var n int fmt.Scanf("%d", &n) palindrome(n) } // Task 4 // Input 1234437 func palindrome(n int) { s := strconv.Itoa(n) found := false for i := 1; i < len(s); i++ { if s[i-1] == s[i] { found = true start, end := i-1, i for j, k := start, end; j ...
package paymentMethods import ( "outlet/v1/bussiness/paymentMethods" "gorm.io/gorm" ) type PaymentMethods struct { gorm.Model ID uint `gorm:"primaryKey"` Name string } func toDomain(record PaymentMethods) paymentMethods.Domain { return paymentMethods.Domain{ ID: int(record.ID), Name: record....
package entity //Group Отдел type Group struct { Meta *Meta `json:"meta"` // Метаданные Id string `json:"id"` // Id отдела AccountId string `json:"accountId"` // Id учетной записи Name string `json:"name"` // Наимнование отдела Index int `json:"index"` // Порядковый н...
package main import ( "fmt" "github.com/xeb/backq/modules/certgen" "github.com/xeb/backq/modules/public" "gopkg.in/alecthomas/kingpin.v2" "time" ) var ( reqport = kingpin.Flag("request_port", "The 0MQ port for publishing requests to bqprivate, e.g. a value of 20000 means binding to 'tcp://*:20000'").Required()...
package unifi import ( "bytes" "encoding/json" "fmt" "net/http" "strings" ) // SiteActiveClient defines an active client device type SiteActiveClient struct { ID string `json:"_id"` IsGuestByUAP bool `json:"_is_guest_by_uap"` LastSeenByUAP int64 `json:"_last_seen_by_uap"` UptimeByUAP int64 ...
//////////////////////////////////////////////////////////////////////////////// // The MIT License (MIT) // // Copyright (c) 2017 Mark LaPerriere // // 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...
package main import ( "strconv" "time" ) func Reducer() { for { for len(reducer_chan) != 0 { incr := <-reducer_chan req_str := "request:" + strconv.Itoa(incr) req_data, _ := RedisGet(req_str) req_data.Result = make(map[int][]string) for _, u := range req_data.Urls { req_data.Result[u.Status_...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package utility import ( "context" "strings" "time" "github.com/mattermost/mattermost-cloud/k8s" "github.com/pkg/errors" log "github.com/sirupsen/logrus" metav1 "k8s.io/apimachinery/pkg/apis/meta...
// Copyright 2020 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 cmd import ( "fmt" "github.com/spf13/cobra" "snmpsim-cli-manager/snmpsim/cmd/deleteSubcommands" ) // deleteCmd represents the deleteSubcommands command var deleteCmd = &cobra.Command{ Use: "delete", Args: cobra.ExactArgs(0), Short: "Deletes the component with the given id", Long: `Completely delete...
package steam import ( "github.com/13k/go-steam/kv" ) const ( messageObjectRootKey = "MessageObject" ) type MessageObject struct { kv.KeyValue } func NewMessageObject() *MessageObject { return &MessageObject{KeyValue: kv.NewKeyValueRoot(messageObjectRootKey)} } func (o *MessageObject) AddObject(key string) *Me...
package middlewares import ( "net/http" ) func SimpleCors(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Access-Control-Allow-Origin", "*") if r.Method == http.MethodOptions { w.Header().Set("Allow", "OPTIONS, POST, GET, PUT") w.Hea...
package tcp import ( "bytes" "encoding/binary" "fmt" "io" "net" "reflect" "strconv" "sync" "syscall" "time" "shadowsocks-go/pkg/config" connection "shadowsocks-go/pkg/connection/tcp/unmaintained" encrypt "shadowsocks-go/pkg/connection/tcp/unmaintained" "shadowsocks-go/pkg/util" "github.com/golang/glog...
package vision import ( "bytes" "encoding/binary" "fmt" "io/ioutil" "os" ) var fp = fmt.Fprintf const ( Image_type_none = uint32(iota) Image_type_gray16 Image_type_rgba Image_type_rgb48 Image_type_gray8 ) type ...
package pbevents import ( "github.com/hyperledger/burrow/binary" "github.com/hyperledger/burrow/crypto" "github.com/hyperledger/burrow/execution/events" "github.com/hyperledger/burrow/txs/payload" ) // this mostly contains tedious mapping between protobuf and our domain objects, but it may be worth // the pain to...
package main import ( "crypto/rand" "encoding/base32" "encoding/hex" "fmt" "github.com/sirupsen/logrus" "golang.org/x/sys/unix" "io" "os" "strconv" "strings" "syscall" "time" ) func GenerateID(l int) string { const ( // ensures we backoff for less than 450ms total. Use the following to // select new ...
package main import "fmt" type person struct { first string last string favTatli []string } // 003 Example struct type arac struct { kapi int renk string } type kamyon struct { arac dortTeker bool } type sedan struct { arac luks bool } func main() { // 001 Example p1 := person{ first: "Kamil", ...
package main import( "github.com/nsf/termbox-go" ) var ( frame = map[string]int { "top": 2, "botton": 3, "right": 2, "left": 2 } wall = "⬜" screan [DisplayY][DisplayX] rune piledBlock [DisplayY][DisplayX] rune ) // 表示枠 func mainScrean() { wallRune := []rune(wall)[0] for r := 0; r < DisplayY; r++ { ...
package main import ( "bytes" "flag" "github.com/ian-kent/go-log/appenders" "github.com/ian-kent/go-log/layout" "github.com/ian-kent/go-log/levels" "github.com/ian-kent/go-log/log" gotcha "github.com/ian-kent/gotcha/app" "github.com/ian-kent/gotcha/http" "net/url" "os" "strconv" "strings" ) var maxlen = 2...
package command import "fmt" func isVersionCommand(args []string) (isVersion bool) { isVersion = args[0] == "version" || args[0] == "-v" || args[0] == "--version" return } func (d *Dispatcher) displayVersion() { if d.version == "" { fmt.Println("version information is not available") return } fmt.Println(d....
package httpServer import ( "log" "net/http" "vrcdb/httpServer/handlers" "vrcdb/httpServer/middlewares" "vrcdb/wsServer" "github.com/gorilla/mux" "github.com/justinas/alice" ) func Init() { log.Println("Initializing http routes...") middlewareChain := alice.New(middlewares.Logger, middlewares.Recover) va...
package webhandlers import ( "database/sql" "encoding/json" "errors" "io/ioutil" "log" "net/http" "github.com/dannylesnik/http-inject-context/models" "github.com/gorilla/mux" ) //GetPerson - func GetPerson(w http.ResponseWriter, r *http.Request) { personID := mux.Vars(r)["id"] log.Printf(" Reuqest URI %s",...
package bst type Queue struct { head *node tail *node } type node struct { Value *Node // Value is a type `Node` of the tree node of BST Next *node } func (q *Queue) IsEmpty() bool { return q.head == nil } func (q *Queue) Enqueue(v *Node) { if q.head == nil { q.head = &node{Value: v} q.tail = q.head } e...
package entity_config import ( "encoding/json" "fmt" "github.com/brooklyncentral/brooklyn-cli/models" "github.com/brooklyncentral/brooklyn-cli/net" ) func ConfigValue(network *net.Network, application, entity, config string) (interface{}, error) { bytes, err := ConfigValueAsBytes(network, application, entity, co...
package server import ( "MORE.Tech/backend/db" "MORE.Tech/backend/models" "github.com/gin-gonic/gin" ) func GetTestQuestions(c *gin.Context) { var result []models.TestQuestion err := db.GetDB().Preload("TestAnswers").Find(&result).Error if err != nil { handleInternalError(c, err) return } handleOK(c, re...
package main import ( "fmt" "os" "golang.org/x/net/html" ) func forEachNode(n *html.Node, pre, post func(n *html.Node)) { if pre != nil { pre(n) } for c := n.FirstChild; c != nil; c = c.NextSibling { forEachNode(c, pre, post) } if post != nil { post(n) } } var depth int func nodeHasChildren(n *htm...
package main import "fmt" func main() { var i byte = 65 var j byte j = 0x61 fmt.Println("소문자 %c 10진수로 %d 입니다", i, j) }
package cmd import ( "bytes" "context" "encoding/json" "io/ioutil" "os" "testing" "time" "github.com/gridscale/gsclient-go/v3" "github.com/gridscale/gscloud/render" "github.com/gridscale/gscloud/runtime" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" ) var changeTime, _ = time.Parse(time.R...
package serve // User user object type User struct { ID string Password string Namespaces map[string]*UserNamespace } //UserNamespace user namespace type UserNamespace struct { Apps map[string]*UserApplication } //UserApplication user application type UserApplication struct { Roles []string } //NewUs...
// 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 invoice import "github.com/mpdroog/invoiced/db" type InvoiceMail struct { From string Subject string To string Body string } type InvoiceEntity struct { Name string `validate:"nonzero"` Street1 string `validate:"nonzero"` Street2 string `validate:"nonzero"` } type InvoiceCustomer struct {...
package main import ( "gopkg.in/alecthomas/kingpin.v2" "os" ) func main() { app := kingpin.New("cloudkey", "Encrypt and decrypt files with key in the cloud.") app.Version("0.0.1") config := app.Command("config", "Create configuration file").Alias("c") configGcp := config.Command("gcp", "Create configuration f...
// Copyright © 2020 Weald Technology Trading // 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 models import ( "github.com/fatih/structs" ) // Teacher holds information for a teacher type Teacher struct { ID string `json:"id" structs:"id" bson:"_id" db:"id"` Name string `json:"name" structs:"name" bson:"name" db:"name"` Age string `json:"age" structs:"age" bson:"age" db:"age"` ...
// Package config contains the flags and defaults for Worker configuration. package config import ( "fmt" "io" "os" "reflect" "sort" "strings" "time" "gopkg.in/urfave/cli.v1" ) var ( defaultAmqpURI = "amqp://" defaultBaseDir = "." defaultFilePollingInterval, _ ...
// Copyright 2019 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 keyboard var activeMediaKeys = map[Key]bool{} func (k Keyboard) HandleMediaKey(keys byte) { // next if keys&1 != 0 { k.CurrentMode.DoKeyDown(MediaNext) activeMediaKeys[MediaNext] = true } else if activeMediaKeys[MediaNext] { k.CurrentMode.DoKeyUp(MediaNext) activeMediaKeys[MediaNext] = false } /...
package test const ( // Endpoint is the slack endpoint which can be used for testing calling code. Endpoint = "https://slack.com/api/api.test" )
// Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. package macaroon_test import ( "testing" assert "github.com/stretchr/testify/require" "storj.io/common/macaroon" ) func TestNilMacaroon(t *testing.T) { mac, err := macaroon.NewUnrestricted(nil) assert.NoError(t, err) assert.NotNil...
package handler import ( "log" "net/http" "strconv" "crud-api-class/domain" "github.com/gin-gonic/gin" ) func Create(c *gin.Context) { c.Request.ParseForm() url := c.Request.Form["url"][0] err := domain.CreateNewElement(url) if err != nil { log.Fatal("fail create: ", err) } c.Redirect(http.StatusFoun...
package hud import ( "io" "time" "github.com/tilt-dev/tilt/pkg/model/logstore" ) var backoffInit = 5 * time.Second var backoffMultiplier = time.Duration(2) type Stdout io.Writer type IncrementalPrinter struct { progress map[progressKey]progressStatus stdout Stdout } func NewIncrementalPrinter(stdout Stdout...
package src; import ( "os/user" "io/ioutil" "github.com/BurntSushi/toml" "github.com/pkg/errors" "log" ) func IdentityOrNameFromCli(arg string) string { user, err := user.Current() if err != nil { return arg; } content, err := ioutil.ReadFile(user.HomeDir + "/.devguard/na...
package gohaystack import ( "encoding/json" "errors" "fmt" "net/url" "regexp" "strconv" "strings" "time" ) // Kind is a supported type for a haystack value type Kind int // Unit represents a unit is a number type Unit *string // NewUnit returns a new unit func NewUnit(u string) Unit { return &u } // NewNu...
// Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. package identity_test import ( "bytes" "context" "crypto" "crypto/x509" "crypto/x509/pkix" "encoding/asn1" "fmt" "os" "runtime" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "storj.io/c...
package tcp import "time" const ( ReadTimeout = time.Minute * 5 //当服务器1分钟内没有收到任何数据,断开客户端连接 ) /* //数据包结构 const ( TypeLen = 2 // 消息类型字节数组长度 LenLen = 2 // 消息长度字节数组长度 SeqLen = 4 // 消息seq字节数组长度 ContentMaxLen =...
// +build !windows,!darwin // 4 november 2014 package ui import ( "fmt" "unsafe" ) // #include "gtk_unix.h" import "C" type progressbar struct { *controlSingleWidget pbar *C.GtkProgressBar } func newProgressBar() ProgressBar { widget := C.gtk_progress_bar_new(); p := &progressbar{ controlSingleWidget: ne...
package utils import ( "os" "github.com/BenLubar/dwarfocr" ) func ReadTilesetFromFile(name string) (*dwarfocr.Tileset, error) { f, err := os.Open(name) if err != nil { return nil, err } defer f.Close() return dwarfocr.ReadTileset(f) }
package main import ( "fmt" "io/ioutil" "os" "strings" "github.com/alexcesaro/log" "github.com/alexcesaro/log/stdlog" "github.com/awalterschulze/gographviz" "gopkg.in/yaml.v2" ) var logger log.Logger func abort(msg string) { logger.Critical(msg) os.Exit(1) } type service struct { Links []string V...
package main import ( "flag" "fmt" "math" "math/rand" "os" "strconv" "strings" "time" ) const ( WALL = " " ROAD = "#" START = "S" FINISH = "F" ) type Point struct { x int y int } func (p1 Point) is(p2 Point) bool { return p1.x == p2.x && p1.y == p2.y } func (p2 Point) opposite(p1 Point) Point {...
package jumphelper import ( "fmt" "log" "net/http" "strings" "time" ) import ( "github.com/LarryBattle/nonce-golang" "github.com/bwesterb/go-pow" "github.com/eyedeekay/gosam" "golang.org/x/time/rate" ) // Server is a TCP service that responds to addressbook requests type Server struct { host string por...
// 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 quickanswers contains helper functions for the local Tast tests // that exercise ChromeOS Quick answers feature. package quickanswers import ( "context" "chro...
// 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 constants contains values used across wallpaper tests. package constants import ( "image/color" "chromiumos/tast/local/chrome/uiauto/nodewith" "chromiumos/tas...
package lennox import "strconv" import "fmt" import "io/ioutil" import "os" import "io" import "os/exec" const TIME_SHORT = 550 const TIME_LONG = 1550 const TIME_4000 = 4350 const TIME_5000 = 5150 const NO_TEMP = 14 const COOL_MODE = 0 const DRY_MODE = 1 const AUTO_MODE = 2 const HEAT_MODE = 3 const FAN_MODE = 4 t...
package authors type berthaAuthor struct { Name string `json:"name"` Email string `json:"email"` ImageURL string `json:"imageurl"` Biography string `json:"biography"` TwitterHandle string `json:"twitterhandle"` FacebookProfile string `json:"facebookprofile"` LinkedinProfile s...
// Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information package sync2_test import ( "context" "testing" "time" "storj.io/common/sync2" "storj.io/common/time2" ) func TestSleep(t *testing.T) { t.Parallel() t.Run("against the real clock", func(t *testing.T) { const sleepError = time.Se...
package LeetCode import ( "fmt" ) func Code124() { head := InitTree() head = &TreeNode{-10, nil, nil} head.Left = &TreeNode{9, nil, nil} head.Right = &TreeNode{20, nil, nil} head.Right.Left = &TreeNode{15, nil, nil} head.Right.Right = &TreeNode{7, nil, nil} fmt.Println(maxPathSum(head)) } /** 给定一个非空二叉树,返回其最大...
package main import "fmt" type Monkey struct { Name string } func (m *Monkey) Climbing() { fmt.Println(m.Name, "can climbing") } //继承 type LittleMonkey struct { Monkey } //定义一个鸟类的能力的接口 type BirdAble interface { Fly() } type FishAble interface { Swim() } //实现接口 func (m *LittleMonkey) Fly() { fmt.Println(m.N...
// 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" "sync" "time" ) func fibonacci(id int, c chan<- int, quit <-chan int, wg *sync.WaitGroup) { defer wg.Done() x, y := 0, 1 for { select { case c <- x: fmt.Println("Sent next value!", id) x, y = y, x+y case <-quit: fmt.Println("!!!quiting...!!! ->", id) return defaul...
package main import ( "flag" ) type input struct { Url string Max int } func (inp *input) Parse() { url := flag.String("url", "http://www.google.com", "the url of the site to be crawled") max := flag.Int("max", 1, "max number of requests to make") flag.Parse() inp.Url = *url inp.Max = *max } func (inp inp...
package sneat type genome struct { numInputs, numOutputs, species int l map[int]linkGene n map[int]neuronGene fitness, fitnessAdjusted float64 } func (g *genome) isLinkDuplicated(in, out int) bool { for _, v := range g.l { if v.from == in && v.to == out { return true ...
package lfsapi import ( "encoding/json" "fmt" "io" "net/http" "regexp" "strconv" "strings" "sync" "github.com/ThomsonReutersEikon/go-ntlm/ntlm" "github.com/git-lfs/git-lfs/config" "github.com/git-lfs/git-lfs/errors" ) var ( lfsMediaTypeRE = regexp.MustCompile(`\Aapplication/vnd\.git\-lfs\+json(;|\z)`) ...
package state_system import ( "encoding/json" "testing" ) func TestNewStateTree(t *testing.T) { tree := NewStateTree() if tree.pendingState != nil { t.Error("Pending state was not nil!") } if tree.activeState != nil { t.Error("Active state was not nil!") } if tree.stateMap == nil { t.Error("Tree did ...
package config import ( "github.com/spf13/viper" "fmt" _ "github.com/go-sql-driver/mysql" "os" "path" ) type Config struct { DB *DBConfig App *AppConfig } type DBConfig struct { Server string DSN string Charset string } type AppConfig struct { Env string MigrationDir string } const co...