text
stringlengths
11
4.05M
// The MIT License (MIT) // Copyright (c) 2014 Christopher Lillthors // 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 limitation the rights // to us...
// Package tuplespace provides an implementations of a tuple space for Go. // // It provides both an in-process asynchronous tuplespace (use // NewTupleSpace) and a RESTful server binary. // // Two storage backends are currently available: leveldb and in-memory. // // To use the in-process tuple space: // // import (...
package orm import ( "fmt" "strings" ) type ResultSet struct { schema *Schema Data MappedEntries } func (r *ResultSet) getTableData(tableName string) (*Table, []Entry, error) { table, err := r.schema.GetTable(tableName) if err != nil { return nil, nil, err } data, found := r.Data[tableName] if !found { ...
package operatorlister import ( "fmt" "sync" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" v1 "github.com/operator-framework/api/pkg/operators/v1" listers "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/listers/operators...
package domain type IdInt struct { Id int64 `json:"id"` } type IdString struct { Id string `json:"id"` }
package main import ( "os" "os/signal" "syscall" "time" log "github.com/sirupsen/logrus" "github.com/bpmericle/go-webservice/cmd/server" "github.com/bpmericle/go-webservice/config" ) func init() { // Log as JSON instead of the default ASCII formatter. log.SetFormatter(&log.JSONFormatter{}) // Output to s...
package main import( "fmt" "time" "math/rand" ) func pinger(a,b int,c chan string){ //<- makes it unidirectional (only send , no receive) fmt.Println("Tourist",a,"is online") time.Sleep(time.Second*time.Duration(b)) fmt.Println("Tourist ",a,"is done having spent",b,"mins online") //c <- "ping" } ...
// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package backoff import ( "context" "math/rand" "time" "tailscale.com/types/logger" ) const MAX_BACKOFF_MSEC = 30000 type Backoff struct { n...
package main import ( "bufio" "fmt" "gopkg.in/mgo.v2" "os" "strconv" "time" //"time" //"io" "io/ioutil" "log" "net/http" //"strconv" "strings" ) type Record_row struct { //Id string `json:"id" bson:"_id,omitempty"` Base_bbl int64 `json:"base_bbl" bson:"base_bbl"` Bin int64 `json...
package configs import "github.com/spf13/viper" func LoadConfig(path ...string) error { dfPath := "configs/" if len(path) != 0 { dfPath = path[0] } viper.SetConfigName("config") viper.AddConfigPath(dfPath) viper.SetConfigType("yaml") return viper.ReadInConfig() }
package event const ( // core events CorePluginsInited = "core/plugins/inited" CorePluginsStarted = "core/plugins/started" CorePluginsStopped = "core/plugins/stopped" // patterns CorePlugins = "core/plugins/*" )
package internal import ( "chapter7/grpcjson/keyvalue" "context" "sync" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) //KeyValue 는 맵을 저장하고 있는 구조체이다. type KeyValue struct { mutex sync.RWMutex m map[string]string } //NewKeyValue 함수는 맵과 컨트롤러를 초기화한다. func NewKeyValue() *KeyValue { return ...
package apiserver import ( "context" "errors" "net" "time" "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/reflection" "google.golang.org/grpc/status" "github.com/prometheus/client_golang/prometheus" "github.com/andywow/golang-lessons/lesson-calendar/inte...
/** * Copyright (c) 2018 ZTE Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and the Apache License 2.0 which both accompany this distribution, * and are available at http://www.eclipse.org/legal/epl-v10.html ...
package main // https://www.hackerrank.com/challenges/common-child import ( "bufio" "fmt" "os" ) func main() { scan := bufio.NewScanner(os.Stdin) scan.Scan() a := scan.Text() scan.Scan() b := scan.Text() mem := make([][]int, len(a)) for i := range mem { mem[i] = make([]int, len(b)) } for i := range m...
package main import ( "context" "fmt" "log" "concurrency" "golang.org/x/sync/errgroup" ) func main() { requests := concurrency.GenerateRequests(concurrency.Count) DoAsync(context.TODO(), requests) } func DoAsync(ctx context.Context, requests [][]byte) { // https://stackoverflow.com/questions/49879322/can-...
package commands import ( "github.com/c0caina/inaWarp/global" "github.com/df-mc/dragonfly/server/cmd" ) type WarpList struct { List list } func (wl WarpList) Run(source cmd.Source, output *cmd.Output) { warps, err := global.WarpSqlite.SelectAll() if err != nil { output.Errorf("[inaWarp] %v", err) return } ...
package models import ( "github.com/astaxie/beego/orm" "strconv" "strings" "time" "tokensky_bg_admin/conf" ) // OtcEntrustOrderQueryParam 用于查询的类 type OtcEntrustOrderQueryParam struct { BaseQueryParam Phone string `json:"phone"` //手机号 模糊查询 //发布时间 StartTime int64 `json:"startTime"` //开始时间 EndTime int64 `j...
package request import ( "testing" ) var Result Request func BenchmarkGetRequest(b *testing.B) { b.ReportAllocs() srvc := NewRequestService() for i := 0; i < b.N; i++ { Result = srvc.GetRequest() } }
// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
package dkim import ( "context" "crypto" "errors" "io" "net/mail" "path/filepath" "runtime/trace" "strings" "time" "github.com/emersion/go-message/textproto" "github.com/emersion/go-msgauth/dkim" "github.com/foxcpp/maddy/internal/address" "github.com/foxcpp/maddy/internal/buffer" "github.com/foxcpp/madd...
package 二维数组 import ( "github.com/Lxy417165709/LeetCode-Golang/新刷题/matrix_util" ) func findNumberIn2DArray(matrix [][]int, target int) bool { height, width := matrix_util.GetHeightAndWidth(matrix) column, row := width-1, 0 for column >= 0 && row <= height-1 { reference := matrix[row][column] if reference == t...
package main import ( "fmt" "log" "net/http" "path" "html/template" ) func main() { fmt.Println("Starting application") //Printer melding om at applikasjonen starter http.HandleFunc("/", Handler) //Setter path og bruker Handler http.ListenAndServe(":8080", nil) //Setter port, og handler } func errorChe...
// Copyright 2020 The Kubernetes Authors. // SPDX-License-Identifier: Apache-2.0 package krusty_test /* import ( "testing" kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest" ) var expected string = ` apiVersion: v1 data: rcon-password: Q0hBTkdFTUUh kind: Secret metadata: labels: app: test-minecr...
package key import ( "io/ioutil" "os" "testing" "time" kyber "github.com/drand/kyber" "github.com/drand/kyber/util/random" "github.com/stretchr/testify/require" ) func TestGroupSaveLoad(t *testing.T) { n := 3 ids := make([]*Identity, n) dpub := make([]kyber.Point, n) for i := 0; i < n; i++ { ids[i] = &I...
/* Sometimes when writing brainfuck code, you feel the need to make it longer than needed to encourage debugging. You could do it by just plopping a >< in there, but what fun is that? You'll need something longer and less NOPey to confuse anybody reading your code. Quick introduction to Brainfuck Brainfuck is an esot...
/* Copyright (c) 2016 Jason Ish * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions...
package handlers import ( "encoding/json" "io/ioutil" "log" "net/http" "github.com/danielhood/quest.server.api/entities" "github.com/danielhood/quest.server.api/repositories" "github.com/danielhood/quest.server.api/services" ) // Quest holds QuestService structure type Quest struct { svc services.QuestServic...
package main import ( "bufio" "fmt" "io" "io/ioutil" "local/notorious/logging" "local/notorious/opts" "os" "strings" ) func main() { o, err := opts.Parse() log := logging.Error(os.Stderr) if err != nil { log.Fatalf("parsing command-line options: %v. Try notorious --help for more information on command-li...
package orm import ( "testing" "time" "github.com/iGoogle-ink/gotil/xlog" "github.com/iGoogle-ink/gotil/xtime" ) var ( dsn = "root:root@tcp(mysql:3306)/school?parseTime=true&loc=Local&charset=utf8mb4" ) type Student struct { Id int `gorm:"column:id;primaryKey" xorm:"'id' pk"` Name string `gorm:"column:n...
package operatorstatus import ( "context" "fmt" "os" "reflect" "time" configv1 "github.com/openshift/api/config/v1" configv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1" "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned" "github....
package DAO import ( "Work_5/object" "github.com/jinzhu/gorm" ) //创建评论记录 func CreateComment(comment *object.Comment, db *gorm.DB) object.ErrMessage { //检查评论信息表是否存在,不存在则创建 if !db.HasTable(&comment) { db.AutoMigrate(&comment) } //创建相应评论记录 db.Create(&comment) return object.ErrMessage{} }
package monkey import ( "../properties" "github.com/hajimehoshi/ebiten" "github.com/hajimehoshi/ebiten/ebitenutil" _ "image/png" "log" ) var image *ebiten.Image //Monkey The Monkey is the lmain character from the game. type Monkey struct { //Position of the upper left corner of the monkey X int //Position of...
package peermgr import ( "encoding/json" "fmt" "io/ioutil" "strings" "testing" "time" "github.com/meshplus/bitxhub/internal/model/events" "github.com/meshplus/bitxhub/internal/executor/contracts" "github.com/Rican7/retry" "github.com/Rican7/retry/strategy" "github.com/meshplus/bitxhub/pkg/cert" "githu...
package main import ( "fmt" "net" "strconv" "encoding/binary" "runtime" "time" "flag" "asocks" "io" ) func handleConnection(conn *net.TCPConn) { err := getRequest(conn) if err != nil { fmt.Println("err:", err) conn.Close() } } func getRequest(conn *net...
// Code generated from /Users/xguzman/Projects/dice/formula/Dice.g4 by ANTLR 4.7.2. DO NOT EDIT. package parser // Dice import "github.com/antlr/antlr4/runtime/Go/antlr" // A complete Visitor for a parse tree produced by DiceParser. type DiceVisitor interface { antlr.ParseTreeVisitor // Visit a parse tree produced ...
// +build gofuzz package api import ( "bytes" "net/http" "net/http/httptest" ) func init() { Routes() } // Fuzz is executed by the go-fuzz tool. Input data modifications are provided and // used to validate API call. func Fuzz(data []byte) int { r := httptest.NewRequest("POST", "/process", bytes.NewBuffer(data...
package main import ( "math" "github.com/fr3fou/beep/beep" "github.com/gen2brain/raylib-go/raygui" rl "github.com/gen2brain/raylib-go/raylib" ) const ( topMargin = 671 ) type Key struct { rl.Rectangle Texture rl.Texture2D PressedTexture rl.Texture2D beep.SingleNote KeyboardKey int IsSemitone bool...
package migrate // Index defines the postgres Index. type Index struct { // Name is the index name. Name string // Type defines the index type. Type IndexType // Columns are the columns specified for the index. Columns []*Column } // IndexType defines the postgres index type. type IndexType int const ( // B...
package main import ( "fmt" "log" "math/rand" "time" ) func worker(c *TTLCache) { //start a never ending loop... for { //...that sets and gets random keys/values //from the shared TTLCache i := rand.Intn(20) k := fmt.Sprintf("%d", i) log.Printf("setting %s=%d", k, i) c.Set(k, i, time.Second*5) i2 ...
// 多个goroutine初始化顺序 package main import "fmt" var c = make(chan bool) func main() { go printName("jd", c) go printName("fish", c) for { select { case single := <-c: fmt.Println(single) } } } func printName(name string, c chan bool) { fmt.Println(name) c <- true }
package main import ( "go-grpc/pb" "go-grpc/services" "log" "net" "google.golang.org/grpc" "google.golang.org/grpc/reflection" ) func main() { // Cria o listener e a porta que irá ouvir lis, err := net.Listen("tcp", "localhost:50051") if err != nil { log.Fatalf("Cold not connect: %v", err) } grpcServer ...
package s3 import ( "bytes" "fmt" "net/http" "net/http/httptest" "strings" "testing" . "github.com/smartystreets/goconvey/convey" ) func TestHelper(t *testing.T) { config := Config{ AccessKeyID: "", Endpoint: "", Region: "", SecretAccessKey: "", BucketName: "", SSL: ...
package libkv import ( "bytes" "encoding/base64" "encoding/json" "net/http" "net/url" "path" "regexp" "strings" "github.com/serverless/event-gateway/event" "github.com/serverless/event-gateway/function" "github.com/serverless/event-gateway/internal/pathtree" istrings "github.com/serverless/event-gateway/i...
package Bootstrap import ( "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" "github.com/kylesliu/gin-demo/App/Repositories/Services" "github.com/kylesliu/gin-demo/Bootstrap/config" "github.com/kylesliu/gin-demo/Routes" "net/http" "strconv" "time" ) func GetApp() *http.Server { route := gin.New() //g...
package mongodb import ( "context" "testing" "github.com/go-ocf/kit/security/certManager" "github.com/go-ocf/cloud/cloud2cloud-connector/store" "github.com/kelseyhightower/envconfig" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func newStore(ctx context.Context, t *testing.T, ...
package main import ( "fmt" "log" "net/http" "strings" ) func (conn *Connection) adminAuthMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) { log.Println("Admin Middleware") // 1. Get cookie. If there is no cookie, redirect to login session, err := store.Get(r, CookieName) if err != ni...
/* struct2elasticMapping enables developers to quickly build a ElasticSearch Mapping from Go types. Currently the Mapping is broken down to basic types (int, byte, string, etc.) and support for more complex types like time.Time (date), IP-Addresses, etc. is missing. Using the special Tag "elastic" for structure membe...
package main import "fmt" type person struct { name string age int } func main() { fmt.Println(person{"satish",29}) fmt.Println(person{name:"kumar",age:22}) fmt.Println(person{name:"Fred"}) fmt.Println(person{age:20}) //fmt.Println(person(20)) //cannot use 20 (type int) as type string in field value s:= pers...
package base import ( "io" "log" "log/syslog" "net/url" ) type Bootstrap struct { name string version Version logging *LoggingAdapter } func NewBootstrap(name string) *Bootstrap { return &Bootstrap{name: name} } func (b *Bootstrap) Version(major, minor, build int) *Bootstrap { b.version.Major = major b...
package routes import ( "go-kemas/controllers" "github.com/gin-gonic/gin" "gorm.io/gorm" ) func SetupRoutes(db *gorm.DB) *gin.Engine { r := gin.Default() r.Use(func(c *gin.Context) { c.Set("db", db) }) r.GET("/tasks", controllers.FindTasks) r.POST("/tasks", controllers.CreateT...
package data import ( "github.com/bububa/oppo-omni/core" "github.com/bububa/oppo-omni/model/data" ) // 小游戏-图表 func QQuickAppGame(clt *core.SDKClient, req *data.QQuickAppGameRequest) (*data.QQuickAppGameResult, error) { req.SetResourceName("data") req.SetResourceAction("Q/quickApp/game") var ret data.QQuickAppGam...
package main import ( "container/list" "fmt" ) func main() { a := list.New() a.PushBack(2) a.PushBack(4) a.PushBack(3) b := list.New() b.PushBack(5) b.PushBack(6) b.PushBack(4) show(a) // 2 -> 4 -> 3 show(b) // 5 -> 6 -> 4 c := addTwoNumbers(a, b) show(c) // 7 -> 0 -> 8 fmt.Println() a.Remove(a.Bac...
package main import ( "google_sheet_parser/App/models" "google_sheet_parser/App/routers" "log" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" _ "github.com/jinzhu/gorm/dialects/mysql" ) func main() { corsConfig := cors.DefaultConfig() corsConfig.AllowHeaders = append(corsConfig.AllowHeaders, "Auth...
/* ==========two structures with the same fields will not be consideredidentical in Go if their fields are not in exactly the same order. */ package main import "fmt" type s1 struct { name string age int profile string qualifications []string } func main() { //var p1 = s1{name: "Ank...
package service import ( "github.com/SungKing/blogsystem/models/dao" "github.com/SungKing/blogsystem/models/entity" ) type TagService struct { } var tagDao = new(dao.TagDao) func (*TagService) Insert(t entity.Tag)(int64,error) { return tagDao.Insert(t) } func (*TagService) Query(pageIndex int32,pageSize int32...
package compute import ( "net/http" "os" "reflect" "testing" "github.com/databrickslabs/databricks-terraform/common" "github.com/databrickslabs/databricks-terraform/internal/qa" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestGetOrCreateRunningCluster_AzureAuth(t *testin...
package main import ( "encoding/json" "github.com/ethereum/go-ethereum/common" "log" "math/big" "sub_account_service/blockchain_server/arguments" "sub_account_service/blockchain_server/config" "sub_account_service/blockchain_server/contracts" myeth "sub_account_service/blockchain_server/lib/eth" "time" ) var...
package main import ( "fmt" "time" ) func grade(n float64) string { var rank = int(n) switch rank { case 10: fallthrough case 9: return "A" case 8, 7: return "B" case 6, 5, 4: return "C" default: return "D" } } func main() { fmt.Println(grade(3)) t := time.Now() switch { case t.Hour() < 12: ...
// Copyright 2015-2018 trivago N.V. // // 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 Problem0202 import ( "fmt" "testing" "github.com/stretchr/testify/assert" ) // tcs is testcase slice var tcs = []struct { n int ans bool }{ { 2, false, }, { 77, false, }, { 19, true, }, // 可以有多个 testcase } func Test_isHappy(t *testing.T) { ast := assert.New(t) for _, tc := r...
package models import ( //"time" "github.com/astaxie/beego/orm" _ "github.com/go-sql-driver/mysql" ) type Album struct { Id int Title string Picture string Keywords string Summary string Created int64 Viewnum int Status int } func (this *Album) Table() string { return "album" } f...
package model import ( "time" "github.com/guregu/null" ) type RushNodeModel struct { Id uint64 `json:"id" xorm:"id int"` NodeName string `json:"nodeName" xorm:"nodeName varchar(256)"` // if it is root, will be null ParentNodeId null.Int `json:"parentNodeId" xorm:"parentNodeId int"` ParentNodeName str...
package currency import ( "context" ) //go:generate mockgen -destination ./mock/mock_service.go -package mocsvc amis/pkg/currency/service CurrencyService type CurrencyService interface { GetCurrency(ctx context.Context, coin string, start int64) (*Currency, error) } type Currency struct { Sources []string `json:"...
package ionic_test import ( "fmt" "github.com/ion-channel/ionic" "github.com/ion-channel/ionic/pagination" ) func ExampleIonClient_GetVulnerabilities() { client, err := ionic.New("https://api.test.ionchannel.io") if err != nil { panic(fmt.Sprintf("Panic creating Ion Client: %v", err.Error())) } vulns, err ...
package mgr import ( "errors" "fmt" "os" "os/user" "path/filepath" "strconv" "strings" "syscall" ) // FS is file system tree. type FS struct { Name string `json:"name"` Mode uint `json:"mode"` Owner string `json:"owner"` Group string `json:"group"` Children []FS `json:"children"` } // ...
//Package reply provides implementation of a reply mangos node. package rep import ( "github.com/go-mangos/mangos" "github.com/go-mangos/mangos/protocol/rep" "github.com/go-mangos/mangos/transport/ipc" "github.com/go-mangos/mangos/transport/tcp" ) type Node struct { url string sock mangos.Socket } type Respon...
package service import "math/rand" const ( redisAddress = "127.0.0.1:6379" //stringLength длина случайной строки stringLength = 20 // errorsList список для записи ошибок errorsList = "errors" // messagesList список для записи сообщений messagesList = "messages" // publisher хранит текущего генератора pub...
package n2s import ( "bufio" "log" "time" "io" "github.com/DavidHuie/n2s/nginx" "github.com/DavidHuie/n2s/statsd" ) // N2S translates NGINX log lines to a summary format accepted by // statsd. N2S polls the source file with a specified pollDuration. type N2S struct { dest io.Writer pollDuration time...
package utils import ( "fmt" "time" ) // CheckUntil regularly check a predicate until it's true or time out is reached. func CheckUntil(interval time.Duration, timeout time.Duration, predicate func() (bool, error)) error { timeoutCh := time.After(timeout) for { select { case <-time.After(interval): predTr...
package preference import ( "fmt" "github.com/blang/semver" ) // GetClientPreferences 获取客户端对应资源配置 func (f ClientPreferences) GetClientPreferences(clientID, clientVersion, clientEnvironment string) (*ClientPreference, error) { version, err := semver.ParseTolerant(clientVersion) if err != nil { return nil, err ...
package main import ( "fmt" "github.com/iwindfree/go-study/eval/lib" ) func main() { fmt.Println("hello") a :=eval.Eval("5 + 3 + 2") fmt.Println(a) }
package util; import ( "crypto/sha1" "crypto/sha256" "crypto/sha512" "encoding/hex" ); // Get the hex SHA1 string. func SHA1Hex(val string) string { hash := sha1.New(); hash.Write([]byte(val)); return hex.EncodeToString(hash.Sum(nil)); } // Get the SHA2-256 string. func SHA256Hex(val string) str...
package c33_diffie_hellman import ( "testing" ) func TestGenerate(t *testing.T) { dh1 := NewDHSystem() dh2 := NewDHSystem() if dh1.Pub == dh2.Pub { t.Errorf("Public keys are equal") } if dh1.SessionKeySHA256(dh2.Pub) != dh2.SessionKeySHA256(dh1.Pub) { t.Errorf("Invalid session keys\n") } }
package main import ( "fmt" "math" ) func main() { fmt.Println(mySqrt(4)) fmt.Println(mySqrt(8)) fmt.Println(mySqrt(10)) } /** x 的平方根 实现 `int sqrt(int x)` 函数。 计算并返回 x 的平方根,其中 x 是非负整数。 由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去。 示例 1: ``` 输入: 4 输出: 2 ``` 示例 2: ``` 输入: 8 输出: 2 说明: 8 的平方根是 2.82842..., 由于返回类型是整数,小数...
// Copyright 2021 PingCAP, 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 i...
package oauth2_test import ( "context" "encoding/json" "github.com/golang/mock/gomock" "github.com/tsingsun/go-oauth2" mocks "github.com/tsingsun/go-oauth2/mocks" "testing" "time" ) func TestRefreshTokenGrant_RespondToAccessTokenRequest(t *testing.T) { ctx := context.Background() client := &Client{} client....
package main import ( "encoding/base64" "fmt" "mysql_byroad/model" "mysql_byroad/mysql_schema" "mysql_byroad/nsq" "strconv" log "github.com/Sirupsen/logrus" ) type Context struct { dispatcher *Dispatcher } type Enqueuer interface { Enqueue(name string, evt interface{}) } type KafkaEventHandler struct { q...
// Write a program which prompts the user to enter a string. The program searches through // the entered string for the characters ‘i’, ‘a’, and ‘n’. The program should print “Found!” // if the entered string starts with the character ‘i’, ends with the character ‘n’, and contains // the character ‘a’. The program shou...
package api type er struct { Message string `json:"message"` }
package users import ( "dapan/dbx" "dapan/model" "log" "net/http" "github.com/gin-gonic/gin" ) func GetUserList(c *gin.Context) { db := dbx.DB // type results type User struct { Username string Name string } var res []User var u []model.UserInfo db.Table("user_infos").Select("user_infos.usernam...
package _struct import ("time" "github.com/marni/goigc" ) type Track struct { HeaderDate time.Time `json:"Header date"` Pilot string `json:"Pilot"` Glider string `json:"Glider"` GliderId string `json:"Glider id"` TrackLength float64 `json:"Track length"` } type TrackDB struct { tracks ...
package gorequests import ( "net/http" "net/url" "sync" ) type CookieJar struct { sync.Mutex cookies map[string][]*http.Cookie } func (cj *CookieJar) SetCookies(u *url.URL, cookies []*http.Cookie) { cj.Lock() defer cj.Unlock() if cj.cookies == nil { cj.Reset() } cj.cookies[u.Host] = cookies } func (cj ...
//~3 7 0 0 48 0 3 7 package main func main() { var i1, i2 int i1, i2 = 3, 4 println(i1 % i2, i1 | i2, i1 & i2, i1 & i2, i1 << i2, i1 >> i2, i1 &^ i2, i1 ^ i2) }
package main import "fmt" func main() { s := []int{1, 2, 3} // len = 3, cap = 3 // [0:2) s1 := s[0:2] // [1,2] fmt.Println(s1) s1[0] = 100 fmt.Println("s的内容是", s, "s1的内容是", s1) fmt.Printf("s1的len = %d, cap = %d, value = %v\n", len(s1), cap(s1), s1) s1 = append(s1, 200) fmt.Println("append之后,s的内容是", s, "...
package log import ( "context" "fmt" "os" "github.com/zdao-pro/sky_blue/pkg/env" ) var ( h Handle ) //Config ... type Config struct { _debugPrintFlag bool _infoPrintFlag bool _warnPrintFlag bool _errorPrintFlag bool _fetalPrintFlag bool // Filter tell log handler which field are sensitive message, use ...
package model import ( "Seaman/utils" "time" ) type TplAreaT struct { Id int64 `xorm:"pk autoincr BIGINT(20)"` Code string `xorm:"not null comment('编号') VARCHAR(100)"` Desp string `xorm:"not null comment('描述') VARCHAR(100)"` Type string `xorm:"comme...
package ui import ( "github.com/askovpen/goated/pkg/msgapi" "github.com/askovpen/gocui" ) var ( // App gui App *gocui.Gui // AreaPosition variable AreaPosition uint16 // ActiveWindow name ActiveWindow string parentWindow string curAreaID int curMsgNum uint32 showKludges bool // StatusLine variable...
/** * database と接続を行う */ package config import ( "fmt" _ "github.com/go-sql-driver/mysql" "github.com/jinzhu/gorm" "log" "os" ) // ConfigDB db seting type ConfigDB struct { User string Password string Host string Port string Dbname string } // ConnectDB returns initialized gorm.DB func Conn...
package backends import ( "encoding/json" "io/ioutil" "log" "github.com/schachmat/wego/iface" ) type jsnConfig struct { } func (c *jsnConfig) Setup() { } // Fetch will try to open the file specified in the location string argument and // read it as json content to fill the data. The numdays argument will only ...
package skyhook import ( "reflect" "testing" ) func TestConversion(t *testing.T) { data := []byte(`output = input + " world" + bang()`) read := func(string) ([]byte, error) { return data, nil } bang := func() string { return "!" } s := New([]string{"bar"}) s.readFile = read actual, err := s.Run("foo.sky", ...
package token import ( "crypto/hmac" "crypto/sha256" "encoding/hex" "encoding/json" "fmt" "strconv" "strings" ) type Token struct { raw string clientId string userName string scopes map[string]bool deviceId string ts int64 hmac []byte } type Error struct { ErrCode int16 `json:"err_co...
/* Copyright 2011 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 to in writing, software di...
package 模拟 func findDiagonalOrder(matrix [][]int) []int { if len(matrix) == 0 { return []int{} } m, n := len(matrix), len(matrix[0]) times := (n + m) / 2 // 循环次数 ans := make([]int, 0, n*m) beginx, beginy, base := 0, 0, 0 for times != 0 { times-- // 向左上遍历 beginx = min(base, m-1) beginy = base - begin...
package analyzer import ( "fmt" "go/ast" "go/types" "path/filepath" "reflect" "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis/passes/inspect" "golang.org/x/tools/go/ast/inspector" ) var InterfaceMustBePtr = &analysis.Analyzer{ Name: "interfacemustbeptr", Doc: "Checks that calls th...
package mysql func NewMysql() { }
package factories import ( sdk "github.com/identityOrg/oidcsdk" "net/url" "time" ) type ( DefaultTokenRequestContext struct { RequestID string PreviousRequestID string RequestedAt time.Time State string RedirectURI string GrantType string ClientId str...
package phpGo import ( // "reflect" ) func InterfaceToInt(val interface{}) { }
package main import ( "fmt" "log" "net" "os" "runtime" "time" "github.com/SommerEngineering/Sync/Sync" "github.com/howeyc/gopass" "golang.org/x/crypto/ssh" ) func main() { // Show the current version: log.Println(`Sync v1.3.2`) // Allow Go to use all CPUs: runtime.GOMAXPROCS(runti...
package test import ( "fwb/core" "log" "runtime" "sgs" "strings" "testing" "time" ) func TestPlay2PvP(t *testing.T) { loadConf() mockClient1 := mockClient{ name: _1P_NAME, clientID: _1P_ID, t: t, } log.Print("client 1 ", mockClient1.name) mockClient2 := mockClient{ name: _2P_NAME, ...