text
stringlengths
11
4.05M
package main import ( "bufio" //"fmt" "os" "time" "github.com/ziutek/dvb" "github.com/ziutek/dvb/linuxdvb/demux" "github.com/ziutek/dvb/linuxdvb/frontend" "github.com/ziutek/dvb/ts" "github.com/ziutek/dvb/ts/psi" ) func fail(err error) { if err != nil { if _, ok := err.(dvb.TemporaryError); !ok { pani...
package 二叉树 func isSymmetric(root *TreeNode) bool { if root == nil { return true } return isMirror(root.Left, root.Right) } // isMirror 是否互为镜像。 func isMirror(A, B *TreeNode) bool { if A == nil && B == nil { return true } if A == nil || B == nil { return false } return A.Val == B.Val && isMirror(A.Left, ...
// Copyright 2016 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 main import ( "bufio" "flag" "fmt" "io" "net" "net/http" "net/url" "os" "strings" "sync" "golang.org/x/net/html" ) type cdnVendor struct { Symbol, Vendor string } var maxURL = 100 //Max number of Url to check per page var cdnVendors = []cdnVendor{ {"cloudfront", "AWS CloudFront"}, {"kunlun", ...
package main import ( "fmt" "time" //"math/rand" "os" ) func main() { fmt.Println("Started the Crashinator™") //randor := rand.New(rand.NewSource(time.Now().UnixNano())) //dozetime := randor.Intn(5) dozetime := 11 fmt.Printf("Waiting for %d seconds\n", dozetime) time.Sleep(time.Duration(dozetime) * time.Sec...
package business import ( "strings" "testing" "github.com/mauleyzaola/challenge/domain" ) // TODO the product price should come from another domain entity, for now we store it along with the product itself func TestBasketAmount(t *testing.T) { voucher := &domain.Product{ Code: "VOUCHER", Price: 5, } tShir...
package htm // Label is a generic container for any input field. type Label struct { widget *Widget // Pointer to widget for rendering html id string // Label id forId string // Field for id class []string // Label classes wrapper []string // Field wrapper classes label string // Label tex...
package main import ( "archive/zip" "fmt" "io/ioutil" "log" "os" "path/filepath" "strings" ) // read all folder in actual folder and recurse through subsequent folders func walkdir(dir string) { files, _ := ioutil.ReadDir(dir) for _, f := range files { if f.IsDir() { // test for arelda SIP if !arel...
package main import ( "fmt" fs "./filestructure" "os" ) var root *fs.FileStruct func main() { var err error root, err = fs.NewDirectoryStruct("root") check(err) insert("hello world") insert("dir1/dir2/") // FIXME: this overwrites previous dir1 and dir2 is gone insert("dir1") root.Print() } func FileP...
package models import "github.com/google/uuid" type Message struct { UID string Content string UserID string } func NewMessage() *Message { return &Message{ UID: uuid.New().String(), } } func (message *Message) SetContent(content string) *Message { message.Content = content return message } func (mes...
package proxy import ( "errors" "fmt" "github.com/tripleblind/random" "golang.org/x/crypto/nacl/secretbox" ) const ( ErrRandom = "failed to retrieve randomness from source: %s" ErrUnseal = "broken seal" ) type NaClProxy struct { key *[32]byte source random.Source } func NewNaClProxy(source random.Source...
package cwb import ( "context" "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" "testing" ) func TestStationObsElements_GetByName(t *testing.T) { elements := StationObsElements{ { ElementName: "TEMP", ElementValue: "5.9", }, } element, err := elements.GetByName("TEMP") if err != nil { t...
// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package numbers // // IntsFindMax given slice of integer, return the maximum value in slice and // its index. // // If data is empty, it will retur...
package main import ( "log" notifier "github.com/AlexsJones/squawker" "github.com/AlexsJones/squawker/services/slack" "github.com/AlexsJones/squawker/services/stackdriver" "github.com/AlexsJones/squawker/services/victorops" vo "github.com/chrissnell/victorops-go" ) func main() { notifierManager := notifier.N...
package main import "time" var toolIndexs = []*Tool{ { Name: "brick", Alias: "brick", BuildTime: time.Date(2020, 3, 31, 0, 0, 0, 0, time.Local), Install: "go get -u github.com/zdao-pro/sky_blue/tool/brick@" + Version, Summary: "brick工具集本体", Platform: []string{"darwin", "linux", "windows"}, ...
package seeds type seed interface { Run() } type Seed struct { }
package myeduate import ( "context" "log" "myeduate/ent" "entgo.io/ent/dialect" _ "github.com/lib/pq" ) func Example_MstCustomer() { // Create an ent.Client with in-memory SQLite database. client, err := ent.Open(dialect.Postgres, "postgresql://root:root123@localhost:5432/eduate?sslmode=disable") if err != n...
// Copyright 2017 The Upspin 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 openstack import ( "flag" "fmt" "io/ioutil" "net/http" "os" "testing" "time" "github.com/gophercloud/gophercloud/openstack" "github.com/g...
package parser import ( "encoding/json" "github.com/chvck/ingredients-parser/pkg/ingredient" "fmt" "strconv" "regexp" "strings" "io/ioutil" "os" "errors" "github.com/kljensen/snowball" "github.com/chvck/ingredients-parser/internal/crfpp" ) // crfppParser parses a set of ingredients by using crfpp (https://...
package leveldb import ( "context" "encoding/json" "errors" "fmt" "strings" "sync" "github.com/jybbang/go-core-architecture/core" "github.com/syndtr/goleveldb/leveldb" "github.com/syndtr/goleveldb/leveldb/opt" ) type adapter struct { client *clientProxy settings LevelDbSettings } type clientProxy struc...
package main import ( "fmt" ) type MyCircularQueue struct { MaxSize int Head int Tail int ValueSlice []int } /** Initialize your data structure here. Set the size of the queue to be k. */ func Constructor(k int) MyCircularQueue { queue := MyCircularQueue{ MaxSize: k+1, Head: 0, Tail: 0, ...
package linkedlist func middleNode(head *ListNode) *ListNode { fast, slow := head, head for fast != nil && fast.Next != nil { fast = fast.Next.Next slow = slow.Next } return slow }
// // // package unique import ( "github.com/ondi/go-cache" ) type Counter interface { CounterAdd(int64) CounterGet() int64 } type Value_t struct { count int64 } func (self *Value_t) CounterAdd(a int64) { self.count += a } func (self *Value_t) CounterGet() int64 { return self.count } type Evict_t[Mapped_t ...
package main import "testing" func TestSumSquareDiff(t *testing.T) { tests := []struct { input int output int }{ {10, 2640}, {100, 25164150}, } for _, test := range tests { result, err := SumSquareDiff(test.input) if err != nil { t.Error(err) } if result != test.output { t.Errorf("Expected...
package cos import ( "bytes" "context" "fmt" "io" "io/ioutil" "net/http" "reflect" "sort" "strconv" "strings" "time" storagedriver "github.com/docker/distribution/registry/storage/driver" "github.com/docker/distribution/registry/storage/driver/base" "github.com/docker/distribution/registry/storage/drive...
package controllers import ( trans "./../../transfer" "./../../transfer/models" "cydex" "cydex/transfer" clog "github.com/cihub/seelog" ) type NodesController struct { BaseController } func (self *NodesController) Get() { page := new(cydex.Pagination) page.PageSize, _ = self.GetInt("page_size") page.PageNum...
package notification import ( "net/url" "strconv" ) func (m Message) AsValues() url.Values { return url.Values{ "title": {m.Title}, "message": {m.Message}, "priority": {strconv.Itoa(m.Priority)}, } }
package client import ( "strings" "github.com/alphatr/acme-lego/common/bootstrap" ) type clientLogger struct{} func (log *clientLogger) Fatal(args ...interface{}) { bootstrap.Log.Fatal(args) } func (log *clientLogger) Fatalln(args ...interface{}) { bootstrap.Log.Fatalln(args) } func (log *clientLogger) Fatalf...
package collections import ( "github.com/stretchr/testify/require" "testing" "github.com/iotaledger/wasp/packages/kv/dict" "github.com/stretchr/testify/assert" ) func TestBasicMap(t *testing.T) { vars := dict.New() m := NewMap(vars, "testMap") assert.Zero(t, m.MustLen()) k1 := []byte("k1") k2 := []byte("k...
package cluster import ( "errors" "fmt" log "github.com/Sirupsen/logrus" "github.com/ch3lo/overlord/configuration" "github.com/ch3lo/overlord/logger" "github.com/latam-airlines/mesos-framework-factory" "github.com/latam-airlines/mesos-framework-factory/factory" ) type Cluster struct { id string sched...
package grains import "errors" const testVersion = 1 const size = 64 func Square(n int) (uint64, error) { if n > size || n < 1 { return 0, errors.New("Out of range, input must be [1-64]") } return 1 << uint64(n-1), nil } func Total() uint64 { var ret uint64 = 0 return ^ret }
package random import ( "fmt" "github.com/MYOB-Technology/pops/lib" "github.com/spf13/cobra" ) var flagRandSecretSize int var flagRandSecretBase64 bool var flagRandSecretNewLine bool var randSecretCmd = &cobra.Command{ Use: "secret", Short: "Create a random secret", Long: `Create a random secret. Print to S...
package main import ( "github.com/gin-gonic/gin" _ "github.com/go-sql-driver/mysql" // "fmt" "log" "github.com/jinzhu/gorm" ) type User struct { gorm.Model Name string Age int64 } type UserTable struct { gorm.Model Name string Age int64 } var db *gorm.DB var err error type UserRequest struct { Name stri...
/* Package writer defines the Writer interface and has a memory writer for testing purposes. To use this application, you should implement a writer that suits your needs. */ package writer import ( "os" "strings" "time" ) // Writer interface has Write and Close methods. type Writer interface { Write(content strin...
package main /* * @lc app=leetcode id=236 lang=golang * * [236] Lowest Common Ancestor of a Binary Tree */ /** * Definition for TreeNode. * type TreeNode struct { * Val int * Left *ListNode * Right *ListNode * */ var foundP, foundQ bool // 返回p结点或者q结点或者公共结点 // 如果遇到第一个是p结点或者q结点,可以直接返回 // 如果左子树没有...
package ctors import ( "net/http" "time" "github.com/imroc/req" ) func NewHttpClient() *http.Client { client := http.Client{ Timeout: 5 * time.Second, } return &client } func NewReqHttpClient(baseClient *http.Client) *req.Req { client := req.New() client.SetClient(baseClient) return client }
package main import ( "bufio" "bytes" "fmt" "io/ioutil" "log" "os" "os/exec" "regexp" "strings" "unicode" "github.com/alecthomas/template" "gopkg.in/yaml.v2" ) func main() { // content, err := ioutil.ReadFile("skrip.yaml") // if err != nil { // log.Fatal(err) // } // tp := ThePackage{} // err = y...
package main import ( "os" "testing" ) /* Testing for desk.go foe testing in go file name should be ends with _test */ // testing for new deck func TestNewDeck(t *testing.T) { d := newDeck() if len(d) != 16 { t.Errorf("Expected deck length 16 but got %v", len(d)) } if d[0] != "Ace of Spades" { t.Errorf(...
package chargeback import ( "context" "time" prom "github.com/prometheus/client_golang/api/prometheus/v1" "github.com/sirupsen/logrus" "golang.org/x/sync/errgroup" "github.com/operator-framework/operator-metering/pkg/chargeback/prestostore" ) const ( // Keep a cap on the number of time ranges we query per re...
package netutil_test import ( "testing" "github.com/AdguardTeam/golibs/netutil" "github.com/AdguardTeam/golibs/testutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestCloneHostPort(t *testing.T) { t.Parallel() assert.Equal(t, (*netutil.HostPort)(nil), (*netutil.HostPor...
/***************************************************************** * Copyright©,2020-2022, email: 279197148@qq.com * Version: 1.0.0 * @Author: yangtxiang * @Date: 2020-08-28 12:04 * Description: *****************************************************************/ package regcenter import "time" type THostStoreToken st...
// 입력 함수 사용하기 /* 다음은 fmt 패키지에서 제공하는 표준 입력 함수입니다. - func Scan(a …interface{}) (n int, err error): 콘솔에서 공백, 새 줄로 구분하여 입력을 받음 - func Scanln(a …interface{}) (n int, err error): 콘솔에서 공백으로 구분하여 입력을 받음 - func Scanf(format string, a …interface{}) (n int, err error): 콘솔에서 형식을 지정하여 입력을 받음 */ //이번에는 콘솔에서 입력을 받아보겠습니다. package...
package state import ( "github.com/hashstone/luago-book/code/go/api" ) type luaValue interface{} func typeOf(val luaValue) api.LuaType { switch val.(type) { case nil: return api.LUA_TNIL case bool: return api.LUA_TBOOLEAN case int64: return api.LUA_TNUMBER case float64: return api.LUA_TNUMBER case str...
package messages type UnreadMsg struct { UserId string `json:"user_id"` RemoteId string `json:"remote_id"` GroupId string `json:"group_id"` Type MessageType `json:"type"` MsgId int64 `json:"msg_id"` Count int64 `json:"count"` Msg Message `json:"msg"` }
package forum import ( "github.com/facebookgo/inject" "github.com/gin-gonic/gin" "github.com/go-pg/pg" "github.com/kapmahc/axe/plugins/nut" "github.com/kapmahc/axe/web" ) // Plugin plugin type Plugin struct { I18n *web.I18n `inject:""` Cache *web.Cache `inject:""` Router *gin.Engine `inject:...
package main import "fmt" func main() { f := "Aman Patel" var input int var t,u string = "first" , "ffh" //multiple variables can be declared in one go fmt.Println("name is",f) fmt.Println(len(f)) fmt.Println("Hello"[0]) //prints ascii value of that character fmt.Println(321325*424521) //simple multipl...
/* You are given a positive integer N. You have to print exactly N+1 positive integers satisfying the following conditions: Exactly one value should appear twice, all the remaining values should appear only once. Sum of all these values should be equal to 2^N. You have to print the values in non-decreasing order. If ...
package main //Create a user defined struct with //the identifier “person” //the fields: //first //last //age //attach a method to type person with //the identifier “speak” //the method should have the person say their name and age //create a value of type person //call the method from the value of type person import...
package model import ( "bytes" "gorm.io/gorm" "time" ) const PlatformWalletLogTableName = "platform_wallet_log" const ( PlatformIncomeSourceWithdraw = 3 // 商户提现手续费 PlatformIncomeSourceTransfer = 4 // 商户代付手续费 PlatformIncomeSourcePay = 5 // 商户代收手续费 ) type PlatformWalletLog struct { Id int64 `gor...
/** 2 * @Author: Nico 3 * @Date: 2020/12/16 10:16 4 */ package _ms2_5mb type ListNode struct { Val int Next *ListNode } func reverseList(head *ListNode) *ListNode { var p, q *ListNode = nil, head if head == nil || head.Next == nil{ return head } for{ if q == nil{ break } n := q.Next q.Next = p ...
package main import ( "time" "fmt" ) func TimeAndTick() { tick := time.Tick(5e8) boom := time.After(1e9) for { select { case <- tick: fmt.Println("tick trigger") case <- boom: fmt.Println("time trigger") } } } func main() { // TimeAndTick() timer := time.NewTimer(1E9) ticker := time.Ne...
package blevebench import ( "bufio" "fmt" "io" "os" "strings" ) type Article struct { Title string `json:"title"` Text string `json:"text"` } type WikiReader struct { file *os.File reader *bufio.Reader } func NewWikiReader(path string) (*WikiReader, error) { f, err := os.Open(path) if err != nil { r...
package main import ( "fmt" "log" "net/http" "encoding/json" "github.com/gorilla/mux" ) type Article struct{ Id int `json:"Id"` Title string `json:"Title"` Desc string `json:"desc"` Content string `json:"content"` } type Articles []Article func returnAllArticl...
package main import ( "fmt" "math/rand" "sync" "time" ) var n int var WG sync.WaitGroup var rwm sync.RWMutex func main() { WG.Add(4) for i:=1;i<=2;i++ { go read(i) } for i:=1;i<=2;i++ { go write(i) } WG.Wait() } func write(i int) { defer WG.Done() rand.Seed(time.Now().UnixNano()) rwm.Lock() fmt.Pr...
package modules import ( "github.com/hpazk/levenshtein-algorithm/app/helper" ) func levenshteinDistance(t, s string) int { target := []rune(t) source := []rune(s) targetLen := len(target) sourceLen := len(source) if targetLen == 0 { return sourceLen } else if sourceLen == 0 { return targetLen } else if ...
package main import ( "gopkg.in/redis.v5" ) var Redis *redis.Client func ConnectDB() { Redis = redis.NewClient(&redis.Options{ Addr: Config.RedisAddr, DB: Config.RedisDB, }) }
package sese import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document01100101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.011.001.01 Document"` Message *TransferInstructionStatusReport `xml:"sese.011.001.01"` } func (d *Docum...
// Copyright 2019 Kuei-chun Chen. All rights reserved. package analytics import ( "encoding/json" "testing" ) func getServerStatusDocs() []ServerStatusDoc { var diag DiagnosticData var docs []ServerStatusDoc d := NewDiagnosticData() diag, _ = d.readDiagnosticFile(DiagnosticDataFilename) for _, ss := range di...
package scraper import ( "better-av-tool/archive" "better-av-tool/log" "errors" "fmt" "github.com/PuerkitoBio/goquery" "net/http" "regexp" "strings" ) type Fc2Scraper struct { doc *goquery.Document docUrl string HTTPClient *http.Client isArchive bool } const ( fc2Url = "https://adult.content...
package billingsystem import ( "github.com/mixnote/mixnote-api-go/src/core/models" "github.com/mixnote/mixnote-api-go/src/core/service/billing_system/merchants" // "github.com/mixnote/mixnote-api-go/src/framework/database" ) type billingSystem struct {} // var db, _ = database.DBConnection("") var EnabledMerchant...
//author 逆雪寒 //version 0.9.1 package main import ( "flag" "log" "fmt" "net/http" "runtime" "bytes" "strconv" "time" "html/template" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) var ( Host string Port string Mongodb string ) func init() { log.SetFlags(log.LstdFlags) flag.StringVar(&Host, "host",...
package main import ( "fmt" ) // 20. 有效的括号 // 给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效。 // 有效字符串需满足: // 左括号必须用相同类型的右括号闭合。 // 左括号必须以正确的顺序闭合。 // 注意空字符串可被认为是有效字符串。 // https://leetcode-cn.com/problems/valid-parentheses func main() { // fmt.Println(isValid("{]")) fmt.Println(isValid("()")) } // 法一:暴力匹配。一旦匹配到一对括号...
package main import ( "bytes" "encoding/xml" "fmt" "io" "net/url" "os" "path" "path/filepath" "regexp" "strings" "time" "github.com/flosch/pongo2" "github.com/lestrrat/go-strftime" "github.com/russross/blackfriday/v2" ) var extensions = blackfriday.NoIntraEmphasis | blackfriday.Tables | blackfriday.F...
package dataplane import ( "context" "github.com/pkg/errors" mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1" "github.com/kumahq/kuma/pkg/core" core_mesh "github.com/kumahq/kuma/pkg/core/resources/apis/mesh" core_manager "github.com/kumahq/kuma/pkg/core/resources/manager" core_model "github.com/kumahq/ku...
package db import ( "context" "encoding/json" "github.com/dgraph-io/dgo" "github.com/dgraph-io/dgo/protos/api" "github.com/pkg/errors" "github.com/shharn/blog/logger" "google.golang.org/grpc" ) var ( dgraphAddress = "dgraph-server-service:9080" ) // MutationData represents a struct to execute multiple mutat...
package server import ( "log" "github.com/FourLineCode/financer/internal/config" "github.com/FourLineCode/financer/pkg/model" "github.com/gofiber/fiber/v2" "gorm.io/driver/sqlite" "gorm.io/gorm" ) type Server struct { app *fiber.App db *gorm.DB log log.Logger } func New(config *config.Config) *Server { a...
package main import "fmt" func buy(work1, work2 bool) (bool, bool, bool) { buy50 := work1 && work2 buy32 := work1 != work2 buyIce := work1 || work2 return buy50, buy32, buyIce } func main() { tv50, tv32, ice := buy(false, false) fmt.Printf("Tv50: %t, Tv32: %t, Ice: %t, Health: %t", tv50, tv32, ice, !ice) }
package algorithm import ( "fmt" "testing" ) var arrary = []int{1, 2, 3, 4, 5, 6} func TestBinary(t *testing.T){ t.Log("testBinary") t.Log(fmt.Sprintf("arrary:%v", arrary)) ret, err := binary(arrary, 1) if err != nil{ t.Fatal(err) } t.Logf("found successfully, ret=%d, value=%d", ret, arrary[ret]) } func T...
package avltree import "testing" func Compare(a, b interface{}) int { _a := a.(int) _b := b.(int) if int(_a) > int(_b) { return 1 } else if int(_a) == int(_b) { return 0 } return -1 } func TestInsert(t *testing.T) { tree := New(Compare) tree.Insert(43) tree.Insert(10) tree.Insert(50) if tree.len != 3 ...
package requests import "time" type TrelloActivity struct { ListID string ListName string CreatorName string CardID string CreateCard string CardName string Type string BoardID string BoardName string } type CalendarEventGoogle struct { Description string EventEnds ti...
package main import ( "bufio" "fmt" "log" "os" "strings" ) const ( ascii_offset byte = 48 ) func checkErr(err error) { if err != nil { log.Fatalf("Error: %v", err) } } func contains(list []string, candidate string) bool { for _, elem := range list { if elem == candidate { return true } } return f...
package booking import "github.com/GoGroup/Movie-and-events/model" // CommentService specifies Booking related service type BookingRepository interface { Bookings(uid uint) ([]model.Booking, []error) // Booking(id uint) (*model.Booking, []error) // UpdateBooking(Booking *model.Booking) (*model.Booking, []error) ...
package utils var Age int = 18
package main import ( "log" "math/rand" "os" "sort" "strconv" "time" "github.com/brianvoe/gofakeit" "github.com/jinzhu/gorm" "github.com/urfave/cli" pb "gopkg.in/cheggaaa/pb.v1" ) /** This file is responsible for creating users/posts/comments using http requests to the apis */ func main() { DB_Init() f...
/* * Copyright 2019 Kopano * * 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 writin...
package main import "fmt" func main() { message := "Hello World" fmt.Printf(message) }
package domain // Nuestra entidad de dominio type Movie struct { ID int `json:"id" gorm:"primary_key"` Title string `json:"title"` Language string `json:"language"` Budget int64 `json:"budget"` Revenue int64 `json:"ah"` IMDB string `json:"imdb"` Country string `json:"country"` } func (mov...
package pangram import "strings" func IsPangram(sentence string) bool { sentence = strings.ToLower(sentence) for i := 'a' ; i <= 'z' ; i++ { if strings.Count(sentence, string(i)) < 1 { return false } } return true }
package problems func GameOfLife(board [][]int) { m := len(board) if m == 0 { return } n := len(board[0]) if n == 0 { return } for i := 0; i < m; i++ { for j := 0; j < n; j++ { num := 0 if i != 0 { if board[i - 1][j] > 0 { num ++ } if j != 0 && board[i - 1][j - 1] > 0 { num ++...
package volume import ( "encoding/json" "errors" "fmt" "strconv" "strings" "time" "github.com/Huawei/eSDK_K8S_Plugin/src/storage/oceanstor/client" "github.com/Huawei/eSDK_K8S_Plugin/src/storage/oceanstor/smartx" "github.com/Huawei/eSDK_K8S_Plugin/src/utils" "github.com/Huawei/eSDK_K8S_Plugin/src/utils/log" ...
package catp import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00800101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:catp.008.001.01 Document"` Message *ATMCompletionAdviceV01 `xml:"ATMCmpltnAdvc"` } func (d *Document00800101) AddMess...
// 比较golang struct的receiver package main import "fmt" func main() { // a1 := A{ "jd", } fmt.Println(a1.Name) a1.SetName() fmt.Println(a1.Name) a1.SetNameByPtr() fmt.Println(a1.Name) fmt.Println("=====") // a2 := &A{ "jd", } fmt.Println(a2.Name) a2.SetNameByPtr() fmt.Println(a2.Name) a2.SetName()...
// Copyright (c) Facebook, Inc. and its affiliates. // All rights reserved. // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. package main import ( "flag" "github.com/golang/glog" "github.com/facebookexperimental/GOAR/confighandle...
package gannettApi import ( "fmt" "strconv" "github.com/michigan-com/gannett-newsfetch/lib" m "github.com/michigan-com/gannett-newsfetch/model" "github.com/michigan-com/gannett-newsfetch/parse/body" ) /* Given an article from the Gannett API (`assetArticle`), return an article that will be saved in mongo */ f...
package libsignal /* #cgo CFLAGS: -W #cgo LDFLAGS: -L. ./lib/libsignal_ffi.a -lpthread -ldl -lm #include "lib/libsignal_ffi.h" SignalPublicKey* uglycast(void* value) { return (SignalPublicKey*)value; } */ import ( "C" ) import ( "unsafe" log "github.com/sirupsen/logrus" ) // PreKeyBundle contains the data requir...
// base/for/allocate. package main import "fmt" func NewErr(i int) error { return fmt.Errorf("%d", i) } func main() { fmt.Println(":=") for i := 0; i < 10; i++ { if err := NewErr(i); err != nil { fmt.Printf("%v %p %p\n", err, &err, err) } } fmt.Println("=") var err error for i := 0; i < 10; i++ { if...
package tsrv import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00900101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:tsrv.009.001.01 Document"` Message *UndertakingAmendmentResponseNotificationV01 `xml:"UdrtkgAmdmn...
package server import ( "chlorine/apierror" "encoding/json" "net/http" ) // JSONResponseWriter structure adds methods to write JSON to the ResponseWriter. type JSONResponseWriter struct { http.ResponseWriter } // WriteJSON writes sequence of bytes to ResponseWriter and adds Content-Type header as "application/js...
package parcels /* import ( "context" "encoding/json" "fmt" "sort" "spWebFront/FrontKeeper/infrastructure/core" "spWebFront/FrontKeeper/infrastructure/log" "time" "github.com/adverax/echo/generic" ) const ( SearchFormatterEntityId = "search.formatter" AnalogFormatterEntityId = "analog.formatter" MarginFor...
// NAlag. package main import ( "flag" "fmt" ) func main() { fs := flag.NewFlagSet("nargtest", flag.ExitOnError) _ = fs.Bool("version", false, "print version") args := []string{"-version", "hello", "world"} if err := fs.Parse(args); err != nil { panic(err) } fmt.Printf("NFlag:%d\n", fs.NArg()) }
package cfrida func Frida_spawn_get_pid(obj uintptr) uint { r, _, _ := frida_spawn_get_pid.Call(obj) return uint(r) } func Frida_spawn_get_identifier(obj uintptr) string { r, _, _ := frida_spawn_get_identifier.Call(obj) return CStrToGoStr(r) }
package library import ( "bytes" "io/ioutil" "net/http" "time" ) var httpClient = &http.Client{ Timeout: 2 * time.Second, } func HttpGet(url string) (string, error) { resp, err := httpClient.Get(url) if err != nil { return "", err } defer resp.Body.Close() result, err := ioutil.ReadAll(resp.Body) return...
package goi import ( "bytes" "fmt" "math/rand" "testing" "time" "unsafe" ) const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" const ( letterIdxBits = 6 // 6 bits to represent a letter index letterIdxMask = 1<<letterIdxBits - 1 // All 1-bits, as many as letterIdxBits ...
/* Copyright © 2022 SUSE 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 writing, software distri...
func getKth(lo int, hi int, k int) int { type kv struct { Key int Value int } var sortedMapping []kv for i := lo; i <= hi; i++ { num := i count := 0 for num != 1 { count++ if num % 2 == 1 { nu...
package model // RecordToSend is a Producer record type RecordToSend struct { Key *[]byte Val *[]byte } // Record is a consumer record type Record struct { Key *[]byte Offset int64 PartKey Message *[]byte Err error }
package s import ( "fmt" ) type SecretValueGetter func(name string) string type KeyVaultClient struct { get_value SecretValueGetter } func NewKeyVaultClient(getter SecretValueGetter) *KeyVaultClient { return &KeyVaultClient{get_value: getter} } func (c *KeyVaultClient) GetSecretValue(name string) string { retu...
package main import ( "net/http" "github.com/apex/log" "github.com/taak-todo/api/internal/server" ) type Application struct { Router http.Handler } func NewApplication() *Application { app := new(Application) routes := []server.Route{ {Method: http.MethodGet, Path: "/health", Handler: app.V1HealthHandler}, ...
package game_map import ( "github.com/faiface/pixel/pixelgl" "github.com/sirupsen/logrus" "github.com/steelx/go-rpg-cgm/gui" "reflect" ) type Storyboard struct { Stack *gui.StateStack InternalStack *gui.StateStack States map[string]gui.StackInterface Events []interface{} //always keep as...
package repository import ( "database/sql" "fmt" "github.com/DATA-DOG/go-sqlmock" "github.com/jinzhu/gorm" "github.com/radyatamaa/loyalti-go-echo/src/domain/model" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "testing" "time" ) type OutletSuite...