text
stringlengths
11
4.05M
package process import "fmt" //因为UserMgr 实例在服务器端有且只有一个 //因为在很多地方都会使用到,因此,我们将其定义为全局变量 var ( userMgr *UserMgr ) type UserMgr struct { onlineUsers map[int]*UseProcess } //完成对userMgr初始化工作 func init() { userMgr = &UserMgr{ onlineUsers: make(map[int]*UseProcess, 1024), } } //完成对onlineUsers添加 func (this *UserMgr)...
// Copyright 2019 GoAdmin Core Team. All rights reserved. // Use of this source code is governed by a Apache-2.0 style // license that can be found in the LICENSE file. package gin import ( "bytes" "errors" "net/http" "net/url" "strings" "github.com/GoAdminGroup/go-admin/adapter" "github.com/GoAdminGroup/go-a...
package qstring import ( "strings" "time" ) const format = "2006-01-02T15:04:05" // DateTimeBuilders are used for querying by datetimes. // // Prefer not using builders directly, instead using the constructors. type DateTimeBuilder struct { builder *strings.Builder } func (b *DateTimeBuilder) EQ(t time.Time) *Bu...
// Package postgres contains an implementation of the storage.Backend backed by postgres. package postgres import ( "context" "errors" "fmt" "sort" "strings" "time" "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/pgconn" "github.com/jackc/pgx/v5/pgtype" "google.golang.org/protobuf/encoding/protojson" "g...
package models import ( "github.com/astaxie/beego/orm" "time" ) //订单提币表 func (a *FinancialOrderWithdrawal) TableName() string { return FinancialOrderWithdrawalTBName() } //查询的类 type FinancialOrderWithdrawalQueryParam struct { BaseQueryParam OrderId string `json:"orderId"` //订单号 } //理财收益表 type FinancialOrder...
package minimark import ( "strings" "testing" c "github.com/aziis98/parser-combinators" "github.com/aziis98/parser-combinators/examples/minimark/doc" "github.com/aziis98/parser-combinators/examples/minimark/parser" "github.com/stretchr/testify/assert" ) var example1 = ` # Prova ## Prova ### Prova Paragraph of...
// Package slicesort contains utilities for easily sorting slices. package slicesort import ( "reflect" "sort" ) type st struct { vxs reflect.Value vf reflect.Value } func (s st) Len() int { return s.vxs.Len() } func (s st) Swap(i, j int) { vi := s.vxs.Index(i) vj := s.vxs.Index(j) t := reflect.ValueOf(vi....
package main import ( "database/sql" "encoding/json" "fmt" "log" "net/http" _ "github.com/lib/pq" ) const ( host = "localhost" port = 5432 pg_user = "USER" password = "PASSWORD" dbname = "DB_NAME" ) var db *sql.DB func main() { initDB() defer db.Close() http.HandleFunc("/", userHandler) l...
package config import ( "fmt" "database/sql" _ "github.com/lib/pq" ) const ( Host = "localhost" User = "hieutm" Password = "hieutm211" DBname = "basicweb" ) func InitDB() (*sql.DB, error) { connStmt := fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=disable", User, Password, Host, DBname) db, err := sql.Open("...
package main import ( "fmt" "sync" ) func main() { c := make(chan int) var wg sync.WaitGroup wg.Add(2) go func() { for i := 0; i < 5; i++ { c <- i } wg.Done() }() go func() { for i := 0; i < 5; i++ { c <- i } wg.Done() }() go func() { wg.Wait() close(c) }() for n := range c { ...
package handler // import ( // "net/http" // "net/http/httptest" // "testing" // ) // func TestAdminCases(t *testing.T) { // httprr := httptest.NewRecorder() // req, err := http.NewRequest("GET", "/v1/admin/cases", nil) // if err != nil { // t.Fatal(err) // } // Cases(httprr, req) // resp := httprr.Result...
// Package select_menu provides a select menu component. package select_menu
package test import "testing" func BenchmarkBubbleSort(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { BubbleSort(GenRandomSlice(10000)) } } func BenchmarkInsertSort(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { InsertSort(GenRandomSlice(10000)) } } func BenchmarkQuickSort(b *tes...
// Package libvirt provides a cluster-destroyer for libvirt clusters. package libvirt
//Package models provide the basic model of the db package models import ( "github.com/2liang/mcache/models/base" ) func Init() { base.DbCache.InitXorm("dbcache") base.DbCache.GetMaster() base.DbCache.GetSlave() }
package errno const ( ESysInvalidPrjHome = 11 ESysInitConfFail = 12 ESysInitLogFail = 13 ESysSavePidFileFail = 14 )
package smpp34 import ( "bytes" "encoding/binary" ) var ( // Required QuerySmResp Fields reqQSMRespFields = []string{ MESSAGE_ID, FINAL_DATE, MESSAGE_STATE, ERROR_CODE, } ) type QuerySmResp struct { *Header mandatoryFields map[string]Field tlvFields map[uint16]*TLVField } func NewQuerySmResp(h...
// Copyright 2020, Homin Lee <homin.lee@suapapa.net>. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "github.com/suapapa/go_devices/pcf8574clcd" "periph.io/x/periph/conn/i2c/i2creg" "periph.io/x/periph/host" ) func...
package pageContext import ( "google.golang.org/appengine/datastore" ) // PageContext datastore: ",noindex" causes json naming problems !!!!!!!!!!!!!!!!!!!!!!!!!! // Page key is the parent key. type PageContext struct { ContextKey *datastore.Key } // PageContexts is a []*PageContext type PageContexts []*PageContex...
package middleware import ( sentinelPlugin "github.com/alibaba/sentinel-golang/adapter/gin" "github.com/alibaba/sentinel-golang/core/system" "github.com/gin-gonic/gin" "go.uber.org/zap" ) // Sentinel 限流 func Sentinel(triggerCount float64) gin.HandlerFunc { if _, err := system.LoadRules([]*system.Rule{ { Met...
package http import ( "net/http" "fmt" "HelloGo/src/http/wp" ) func Request(rw http.ResponseWriter, r *http.Request) { r.ParseForm() fmt.Fprintln(rw, "xxxxxxxxxxxxxxx") } func StartService() { wp.RunService() }
package lexer // import( // "dictionary" // ) import( "github.com/Evedel/fortify/src/dictionary" ) // constants for token guessing const ( s_udf = iota s_str = iota s_nmb = iota s_cmd = iota ) func Tokenise(source string) (Tokenised []dictionary.Token) { curpos := 0 var t dictionary.Token t.Id = dictionar...
package statemachine // State contains the name of the state type State struct { Name string } // NewState returns a new instance of the State struct func NewState(name string) *State { return &State{ Name: name, } }
func uniquePaths(m int, n int) int { if m == 1 || n == 1 { return 1 } if m > n { return c(m+n-2, n-1) } return c(m+n-2, m-1) } func c(m, n int) int { divident := 1 for i := m; i > m - n; i-- { divident *= i } for i := n; i > 0; i-- { divident /= i ...
package main import ( "log" "net/http" "strconv" "github.com/vlad-belogrudov/gopl/pkg/color" "github.com/vlad-belogrudov/gopl/pkg/surface" ) func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { var err error if err = r.ParseForm(); err != nil { log.Println("cannot parse para...
package db import ( "database/sql" "strconv" "sync" "github.com/textileio/go-textile/pb" "github.com/textileio/go-textile/repo" "github.com/textileio/go-textile/util" ) type NotificationDB struct { modelStore } func NewNotificationStore(db *sql.DB, lock *sync.Mutex) repo.NotificationStore { return &Notifica...
/* * KSQL * * This is a swagger spec for ksqldb * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package swagger type ShowListResponseQueries struct { QueryString string `json:"queryString,omitempty"` Sinks string `json:"sinks,omitempty"` Id...
package util // TransportStatus is an int alias that indicates the status of a Transport type TransportStatus int // Various statuses for transports const ( Unknown TransportStatus = iota Running Stopped )
/* * Copyright (c) 2019. Alexey Shtepa <as.shtepa@gmail.com> LICENSE MIT * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. */ package bindata import "testing" func eqTest(t *testing.T, p, b, r interface{}) { if p != r { t.Erro...
package resolver import ( "github.com/taktakty/netlabi/testdata" "github.com/stretchr/testify/require" "strconv" "strings" "testing" ) func TestIpaddrMutations(t *testing.T) { testData := ipSegmentTestData t.Run("Update", func(t *testing.T) { ipaddrID := testData[1].Ipaddr[1].ID p := struct { id st...
/* Copyright 2021 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, ...
package responses import ( "time" ) type ( ItemResponse struct { ID uint64 `json:"id"` GithubURL string `json:"github_url"` Author string `json:"author"` Name string `json:"name"` Description string `json:"description"` CreatedAt time.Time ...
package components import ( "html/template" "github.com/GoAdminGroup/go-admin/template/types" ) type PopupAttribute struct { Name string ID string Body template.HTML Footer template.HTML FooterHTML template.HTML Title template.HTML Size string HideFooter bool Height ...
// Copyright 2021 BoCloud // // 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 service import ( "go/internal/pkg/model" "gorm.io/gorm" ) type Session interface { Create(m *model.Session, tx *gorm.DB) (*model.Session, error) Update(m *model.Session, tx *gorm.DB) error Delete(m *model.Session, tx *gorm.DB) error FindOneBy(criteria map[string]interface{}) (*model.Session, error) Fi...
// 419 scams - "confidence trick". Aka "Nigerian" // en.m.wikipedia.org/wiki/419_scams. package combat var ( scammerPhrases = []string{ "from the desk of barrister", "your assistance is needed", "I am seeking for a reliable person", "role as the next of kin", "you will henceforth stand to get", "millions...
package problem0225 // MyQueue 队列实现 type MyQueue struct { data []int size int capacity int } // InitQueue 初始化队列 func InitQueue() MyQueue { return MyQueue{ data: make([]int, 10), size: 0, capacity: 10, } } // Push 入队列 func (queue *MyQueue) Push(x int) { if queue.size >= queue.capacity { ...
// Copyright 2020. Akamai 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 law or agreed t...
package textbox type Backend interface { Size() (int, int) EventsChan() chan Event Flush(*Buffer) Close() }
package main import "fmt" func isPrime(x int) bool { for k := 2; k < x; k++{ if x % k == 0{ return false } } return true } func main() { for k := 2; k < 200000; k++{ if isPrime(k) { fmt.Print("X") } else { fmt.Print("O") } } }
package main import "fmt" import "reflect" const ( a = 10 d int = 30 ) func main() { var b uint8 b = 20 m := a + b fmt.Println(m) fmt.Println(reflect.TypeOf(a)) c := 0x7f fmt.Println(reflect.TypeOf(c)) n := b + c fmt.Println(n) l := b + d fmt.Println(l) }
package frida_go import ( "fmt" "github.com/a97077088/frida-go/cfrida" jsoniter "github.com/json-iterator/go" "unsafe" ) type Bus struct { CObj *BusSignalConnect } func (b *Bus) Post(message interface{},data []byte) { cfrida.Frida_bus_post(b.instance,jsoniter.Wrap(message).ToString(),data) } func (b *Bus) A...
package config var Config = struct { Fields []string Services []string PrintColor PrintColor PrintFormat PrintFormat }{ // 日志打印字段 Fields: []string{ "time", "file", "msg", }, // 预加载的服务名 Services: []string{ "service-etrip-approval", "service-etrip-bill", "service-finance-bill", "service-...
package main import( "fmt" "strconv" "sort" "sync" // "runtime" ) func SingleHash() string { var data string fmt.Scanln(&data) md5 := DataSignerMd5(data) //cannot be multiplexed wg := &sync.WaitGroup{} crc32Chan := make(chan string) wg.Add(1) go func(data string, result chan string) { result <- DataSi...
package main import "fmt" func main() { fmt.Println("Hello from development") }
/* Copyright 2019 The MayaData 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, s...
package main import ( "fmt" "log" "reflect" "strconv" ) var input string = "input.txt" type Instruction struct { command string parameter int visited bool } func NewInstruction(instruction string, parameter string) *Instruction { n, e := strconv.Atoi(parameter) if e != nil { log.Printf("Error in code...
package main import "fmt" func main() { fmt.Println("Score to number grades") n := 0 fmt.Printf("Enter score > ") fmt.Scanf("%d", &n) if n >= 90 { fmt.Println("A+") } else if n >= 80 { fmt.Println("A") } else if n >= 70 { fmt.Println("B") } else if n >= 60 { fmt.Println("C") } else if n >= 50 { fmt...
// Copyright 2020 MongoDB 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 bertymessenger import ( "context" "net" "google.golang.org/grpc/test/bufconn" ) func mkBufDialer(l *bufconn.Listener) func(context.Context, string) (net.Conn, error) { return func(context.Context, string) (net.Conn, error) { return l.Dial() } }
package problems import ( "fmt" "reflect" "testing" "github.com/stretchr/testify/require" ) func Test_sortedSquares(t *testing.T) { type args struct { A []int } tests := []struct { name string args args want []int }{ { name: "worst 1", args: args{ A: []int{-2, -2, -2, -2, 3}, }, wan...
package line_login const ( baseUrl = "https://legy-jp-addr.line.naver.jp" registerUrl = baseUrl + "/api/v4/TalkService.do" authRegisterUrl = baseUrl + "/api/v4p/rs" verifyUrl = baseUrl + "/LF1" userAgent = "Line/10.17.0" lineApp = "IOSIPAD\t10.17.0\tiPad OS\t14.1" )
package fsync import ( "errors" "fmt" "net" "os" ) //var getRootDir = func() string { // d, _ := os.Getwd() // return d + "/tmp/" //} type Handler struct { Rw ReadWrite } func (h *Handler) setMsgType(msgType int64) { h.Rw.write64(msgType) } func (h *Handler) setReq(req interface{}) { h.Rw.writeReq(req) } fu...
package ecode // All common ecode var ( OK = add(0) // 正确 NotModified = add(-304) // 木有改动 TemporaryRedirect = add(-307) // 撞车跳转 RequestErr = add(-400) // 请求错误 Unauthorized = add(-401) // 未认证 AccessDenied = add(-403) // 访问权限不足 NothingFound = add(-404) // 啥都木有 MethodNotAllowed ...
/* Links * http://daqutoxevy.github.com/1.html * http://daqutoxevy.github.com/2.html * http://daqutoxevy.github.com/3.html * http://daqutoxevy.github.com/4.html * http://daqutoxevy.github.com/5.html * http://daqutoxevy.github.com/6.html * http://daqutoxevy.github.com/7.html * http://daqutoxevy.github.com/8.html * http:...
// We add file / line to the log. package logging import ( "flag" "fmt" "log" "path" "runtime" ) var vFlag = flag.Int("v", 1, "") func getFileLinePrefix() string { if _, file, line, ok := runtime.Caller(2); ok { return fmt.Sprintf("[%s:%d] ", path.Base(file), line) } return "" } func Fatal(v ...interface...
package xmpp import ( "encoding/xml" ) const ( NodeAdHocCommand = "http://jabber.org/protocol/commands" ActionAdHocExecute = "execute" ActionAdHocNext = "next" ActionAdHocCancel = "cancel" StatusAdHocExecute = "executing" StatusAdHocCompleted = "completed" StatusAdHocCanceled = "canceled" TypeAdHoc...
// Copyright 2020. Akamai 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 law or agreed t...
package nats import ( "os" ) // NATS var ( NATSURL = os.Getenv("NATS_SERVER_URL") DEFAULTMAXMESSAGES = os.Getenv("NATS_DEFAULT_MAX_MESSAGES") )
package auth import ( "strconv" "testing" "github.com/uhppoted/uhppoted-lib/kvs" ) func TestValidateHOTPWithValidOTP(t *testing.T) { hotp := HOTP{ increment: 8, secrets: kvs.NewKeyValueStore("test:secrets", func(v string) (interface{}, error) { return v, nil }), counters: struct { *kvs.KeyValueStore ...
package main import ( "os" "time" "github.com/prometheus/client_golang/prometheus" ) var ( Resolution int64 = 10000 metrics = prometheus.NewGauge(prometheus.GaugeOpts{ Name: "tmp_file_age", Help: "Age of /tmp/testfile", }) ) func GetCollector() prometheus.Collector { return metrics } func UpdateMetric(...
// Copyright 2020 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...
// 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 entities import ( "fmt" ) // User is a user's info struct type User struct { Id string `json:"id"` // Định nghĩa tên trường hiển thị trong JSON Name string `json:"name"` Password string `json:"password"` } type Url struct { ID string `json:"id"` UserName string `json:"username"` LongUr...
package controller import ( "github.com/gin-gonic/gin" ) var R *gin.Engine func init() { R = gin.Default() R.Static("/static","./static") user() }
// Copyright 2015 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 glogger import ( "net/http" ) type readableResponseWriter struct { writer http.ResponseWriter statusCode int length int } func (writer *readableResponseWriter) WriteHeader(code int) { writer.statusCode = code writer.writer.WriteHeader(code) } func (writer *readableResponseWriter) Write(b []byt...
/* * @lc app=leetcode id=10 lang=golang * * [10] Regular Expression Matching */ package main /* Solution 1: */ func isMatch(s string, p string) bool { if len(p) == 0 { return len(s) == 0 } firstCharMatch := len(s) > 0 && (s[0] == p[0] || p[0] == '.') if len(p) > 1 && p[1] == '*' { return firstCharMatch && ...
package cache import ( "fmt" "testing" ) func TestGet(t *testing.T) { //Set("server",[]byte("haha")) bytes, e := Get("server") fmt.Printf("%s err = %v \n", bytes, e) }
// Copyright 2014 Chris Monson <shiblon@gmail.com> // // 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 heap import "testing" func TestTopKFrequent(t *testing.T) { arr := topKFrequent([]int{1, 1, 1, 2, 2, 3}, 2) if !(arr[0] == 2 && arr[1] == 1) { t.Fail() } }
package controllers import ( "fmt" "github.com/gopherchina/website/models" ) type MainController struct { baseController } func (this *MainController) Get() { name := this.Ctx.Input.Param(":name") if name == "" { this.Data["Title"] = "GopherChina" this.Data["indexActive"] = true this.TplNames = "index.tp...
package main import ( "fmt" "log" "strconv" "strings" "net/http" "io/ioutil" ) type podcast struct { Name string Image string Episodes []episode } type episode struct { Filename string Size int } var podcasts map[string]podcast var mediaEndings = []string{"mp3", "ogg", "wav", "mp4", "webm"} v...
package catapult import ( "net" "net/http" "time" ) type Client struct { RequestTimeout time.Duration context *Ctx rawClient *http.Client } var ( DefaultRequestTimeout = time.Second * 20 DefaultExpectContinueTimeout = time.Second DefaultTLSHandshakeTimeout = time.Second DefaultDialTime...
package client import ( "encoding/json" "fmt" "path/filepath" "github.com/go-resty/resty/v2" "github.com/ophum/humstack-redeployment/pkg/api" ) type RedeploymentClient struct { scheme string apiServerAddress string apiServerPort int32 client *resty.Client headers map[string]...
package request import ( "context" "encoding/json" "fmt" "io/ioutil" "net/http" "net/http/httptest" "net/http/httputil" "net/url" "reflect" "strconv" "testing" "github.com/stretchr/testify/require" ) func TestRequest(t *testing.T) { tests := []struct { name string // default "[unnamed]" m...
package main import ( "encoding/json" "fmt" "github.com/apache/rocketmq-client-go/core" log "github.com/cihub/seelog" "rocketmq-filemgr/src/common" "rocketmq-filemgr/src/rocketmqMy" "runtime" "strconv" "time" // "net/http" // _ "net/http/pprof" ) type rocketmqXclean struct { //Implement xclean's taskDealM...
package controller import ( "context" "encoding/json" "errors" "github.com/go-redis/redis/v8" "log" "projja_exec/graph" "projja_exec/model" "strconv" "time" ) func (c *controller) ListenExecStream(ctx context.Context) { for { xStreamSlice := c.Rds.XRead(ctx, &redis.XReadArgs{Block: 0, Streams: []string{"e...
package cmd import ( "context" "flag" "fmt" "github.com/jmoiron/sqlx" "github.com/soulmonk/go-grpc-http-rest-microservice-tutorial/pkg/logger" //"github.com/jmoiron/sqlx" TODO "log" // postgres driver _ "github.com/lib/pq" "github.com/soulmonk/go-grpc-http-rest-microservice-tutorial/pkg/protocol/grpc" "g...
package main import ( "html/template" "net/http" ) func render(w http.ResponseWriter, path string, data interface{}) error { tpl := template.Must(template.ParseFiles("static/template/header.html", "static/template/footer.html", path)) return tpl.ExecuteTemplate(w, "content", data) }
package btree import ( "fmt" "gosearch/pkg/crawler" "testing" ) func TestAdd(t *testing.T) { tr := New() testCases := []struct { wantErr bool ErrorText string Want *crawler.Document }{ { wantErr: false, ErrorText: "", Want: &crawler.Document{ uint64(2), "", "", }, }, ...
package graph import ( "testing" ) func TestTraverse(t *testing.T) { // com := Node{"COM"} }
package main import ( "fmt" "flag" "os" "path/filepath" ) // Subdirs for the expected project structure const templatesDirName = "templates" // Command-line flag for where to put the generated website. var outputDir string const outputDirFlag = "o" // Command-line flag for the directory containing project data....
/* Copyright (c) 2017 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 main import ( "github.com/gorilla/csrf" "github.com/gorilla/mux" "github.com/justinas/alice" "net/http" ) func (app *application) routes() http.Handler { // common middleware stdMiddleware := alice.New(app.recoverPanic, app.logRequest, secureHeaders) dynMiddleware := alice.New(csrf.Protect([]byte(app.s...
package main import ( "bufio" "fmt" "log" "math" "os" "strconv" "strings" "time" ) func main() { // 너구리 한 쌍은 한 달 후에 다른 새끼 너구리 한 쌍을 낳습니다. // 이 새끼 너구리 한 쌍은 한 달 동안 성체가 되며 성체가 된 너구리 한 쌍은 다시 한 달 후에 다른 새끼 너구리 한 쌍을 낳습니다. // 이미 성체가 된 너구리 부부는 달마다 새끼 너구리를 한 쌍씩 낳는다고 가정할 때, n달 후의 너구리 수를 구하는 함수를 작성하세요. (단, 이 너구리들은 죽지 않...
package internal import ( "bytes" "encoding/json" "fmt" "io" "log" "mime/multipart" "net/http" "os" ) type SendFileCommand struct { wsc *WSClient } func (cmd *SendFileCommand) Send(filepath string) (*http.Response, error) { log.Println("Sending shot:", filepath) // Prepare endpoint data to send the file ...
package models import( "github.com/astaxie/beego/orm" _ "github.com/go-sql-driver/mysql" "fmt" "time" "github.com/astaxie/beego" ) func init() { dbhost := beego.AppConfig.String("dbhost") dbport := beego.AppConfig.String("dbport") dbuser := beego.AppConfig.String("dbuser") dbpassword := beego.A...
/* Copyright 2021 The Nuclio 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, soft...
package main import ( "fmt" "math/rand" "time" ) func intersect(a []int, b []int) { l := a m := b if len(a) >= len(b) { l = b m = a } var result []int for _, i := range l { for _, j := range m { if i == j && result == nil { tmp := []int{i} result = tmp } else if i == j { result = appe...
package gedcom_test import ( "testing" "github.com/elliotchance/gedcom" "github.com/elliotchance/tf" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/stretchr/testify/assert" ) var ( // John and Jane share the same pointer on purpose. They will be used for // pointer comparis...
// Copyright © 2020 Attestant Limited. // 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 data_test import ( "accountapi/data" "encoding/json" "strings" "testing" ) // TestRecordType for testing unmarshalling JSON values. type TestRecordType struct { TestType data.RecordType `json:"testType"` } // TestValidRecordType verifies proper constraints for consts ("enums"), parsing and unmarshalling...
// No Exercício #06 da seção "Exercícios", usamos for range para percorrer uma slice de string que representava uma lista de itens a comprar no mercado. Agora, resolva o mesmo exercício usando a sintaxe básica da instrução for (sintaxe apresentada aqui). package main import "fmt" func main() { var lista = []string{...
package main import ( "fmt" "net/http" "runtime" "search-package/controllers" "strconv" ) var port = 3000 func main() { runtime.GOMAXPROCS(4) controllers.RegisterSearchController() fmt.Printf("%s %d \n", "Server running on port", port) http.ListenAndServe("localhost:"+strconv.Itoa(port), nil) }
package solutions /* * @lc app=leetcode id=1 lang=golang * * [1] Two Sum */ /* Your runtime beats 96.22 % of golang submissions Your memory usage beats 48.53 % of golang submissions (4.2 MB) */ // @lc code=start func twoSum(nums []int, target int) []int { t := make(map[int]int) for i := 0; i < len(nums); i++ {...
package leetcode import "testing" func TestLargestSumAfterKNegations(t *testing.T) { if largestSumAfterKNegations([]int{4, 2, 3}, 1) != 5 { t.Fatal() } if largestSumAfterKNegations([]int{3, -1, 0, 2}, 3) != 6 { t.Fatal() } if largestSumAfterKNegations([]int{2, -3, -1, 5, -4}, 2) != 13 { t.Fatal() } if la...
package filewriter import . "backend/armarchitecture" type Registers struct { registers []Register }
package events import ( "context" "sync" "testing" "time" "github.com/cloudfly/ecenter/pkg/sender" "github.com/cloudfly/ecenter/pkg/types" "github.com/cloudfly/ecenter/test" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" log "github.com/sirupsen/logrus" ) var ( mockSender *Moc...
package cli import ( "fmt" "os/exec" "syscall" ) var ( scwcli = "../../scw" publicCommands = []string{ "help", "attach", "commit", "cp", "create", "events", "exec", "history", "images", "info", "inspect", "kill", "login", "logout", "logs", "port", "products", "ps", "rename", "restart", "rm", "r...