text
stringlengths
11
4.05M
package main import ( "bytes" "fmt" "sync" ) func main() { var s string buf := bytes.NewBufferString(s) rwmutex := new(sync.RWMutex) wg := new(sync.WaitGroup) for i := 0; i <= 100; i++ { wg.Add(1) go func(i int) { defer wg.Done() rwmutex.Lock() defer rwmutex.Unlock() fmt.Fprintln(buf, "hello:...
/* =====================defer keyword============= #defer works on LIFO #postpones execution of function util surrounding function returns #widely used for output and input function and saves you from clos a open file #deferred function executed in LIFO order. */ package main import ( "fmt" ) func d1() { for i :...
package gowally import ( "fmt" "io/ioutil" "net/http" "github.com/Upper-Beacon/gowally/gohttp" ) var ( githubHTTPClient = getGithubClient() ) func getGithubClient() gohttp.HTTPClient { client := gohttp.New() commomHeaders := make(http.Header) commomHeaders.Set("Authorization", "Bearer ABC-123") client.S...
package main import ( "log" "fmt" "time" ) func main() { str := "10s" duration, err := time.ParseDuration(str) if err != nil { log.Fatal(err) } seconds := duration.Seconds() fmt.Println(seconds) }
package main import "fmt" func main() { fmt.Println(len("Zhuhry")) fmt.Println("Muhammad Zhuhry"[0]) fmt.Println("Muhammad Athallah Zhuhry") }
package dae import ( "encoding/xml" "fmt" "strconv" ) // COLLADA declares the root of the document that contains some of the content // in the COLLADA schema. type COLLADA struct { Version string `xml:"version,attr"` Asset *Asset `xml:"asset"` LibCameras *LibCameras `xml:"library_cameras"` LibLights *Li...
package main import ( "os" "testing" ) var targetNumber int = 1024 func TestBuffer_Read(t *testing.T) { sl := make([]byte, 0, 4) b := newMp4Buffer(sl) filename := "test_file_large" fp, e := os.Open(filename) if e != nil { t.Errorf("failed to open test file: %s\n", filename) return } defer func(fp *os.F...
package httpserver import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "net/http/cookiejar" "net/http/httptest" "net/url" "strings" "testing" "github.com/ekotlikoff/gochess/internal/model" matchserver "github.com/ekotlikoff/gochess/internal/server/backend/match" gateway "github.com/ekotlikoff/g...
// Copyright 2018 Diego Bernardes. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package flare import ( "context" "net/url" "time" "github.com/pkg/errors" ) // Resource represents the apis Flare track and the info to detect changes o...
package component import ( "fmt" "gone/utils" ) /** * * Create BY YooDing * * Des: application console menus * * Time: 2019/7/5 8:11 PM. * * <a href="https://github.com/YooDing/gone">Github<a> */ var ( input string ) func Menus() { fmt.Println("\n 输入数字选择功能:\n") fmt.Println(" 1 - 安装JDK \n") fmt.Print...
/* Copyright IBM Corporation 2020 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 service import ( "bufio" "bytes" "encoding/json" "mime" "net/http" "path/filepath" "strings" "time" "github.com/ONSdigital/florence/config" "github.com/ONSdigital/log.go/log" "github.com/gorilla/mux" ) // generated files constants const ( assetStaticRoot = "../dist/" assetLegacyIndex = "../dist...
package sqlite import ( "database/sql" "errors" _ "github.com/mattn/go-sqlite3" ) type ConnSqlite struct { } type ConnSqliteInterface interface { SqliteConnInit() *sql.DB AutoDropDB() error } func (sqliteConn *ConnSqlite) SqliteConnInit() *sql.DB { result, err := sql.Open("sqlite3", "./db/sqlite/pembukuan_db"...
package service import ( "context" "fmt" "net/http" "github.com/go-ocf/cloud/cloud2cloud-gateway/store" "github.com/gorilla/mux" ) type retrieveDeviceSubscriptionHandler struct { s store.Subscription } func (c *retrieveDeviceSubscriptionHandler) Handle(ctx context.Context, iter store.SubscriptionIter) error ...
package main import ( "context" "fmt" "os" "github.com/libp2p/go-libp2p" circuit "github.com/libp2p/go-libp2p-circuit" quic "github.com/libp2p/go-libp2p-quic-transport" "github.com/libp2p/go-tcp-transport" ma "github.com/multiformats/go-multiaddr" ) func main() { publicIP := os.Getenv("RELAY_IP") factory :...
package telehash import ( "flag" "fmt" "log" "net" "telehash/exchange" "telehash/telex" ) var ( port = flag.Int("port", 4242, "Specify the UDP port to listen on") ) func init() { flag.Parse() } func main() { exchange, err := listener.New((*port)) if err != nil { log.Fatal(err) } defer exchange.Close...
package utils import "os" func GetConfig() string { environment := os.Getenv("ENV") if len(environment) == 0 { environment = "development" } return environment }
package keystone import ( "errors" "fmt" "github.com/gophercloud/gophercloud" "github.com/gophercloud/gophercloud/openstack" "github.com/gophercloud/gophercloud/openstack/utils" ) func createIdentityV3Provider(options gophercloud.AuthOptions) (*gophercloud.ProviderClient, error) { client, err := openstack.NewC...
package apicore import ( "testing" ) func TestAddMiddleware(t *testing.T) { input := map[string]int{"t1": 1, "t2": 4, "t3": 3, "t4": 2} want := []string{"t1", "t4", "t3"} for key, value := range input { AddMiddleware(func() MiddleWare { return t_middleware{name: key, index: value} }) } index := 0 for i,...
/* * untangle.go * This is the main query handling code for the Untangle DNS filter proxy * We lookup the reputation and categories for inbound queries and then * consult the customer policy to make the allow or block decision. */ package untangle import ( "bufio" "context" "encoding/json" "fmt" "net" "tim...
package main func main() { ch := make(chan int) go func(sc chan<- int) { for i := 0; i < 100; i++ { ch <- i } close(ch) }(ch) for v := range ch { println("Value:", v) } println("done") }
package main import ( "github.com/PuerkitoBio/goquery" "github.com/labstack/echo" "github.com/labstack/echo/engine" "github.com/labstack/echo/test" "github.com/stretchr/testify/assert" "net/url" "os" "strings" "testing" ) var server *echo.Echo var testUser string = "testUser" var testPW string = "testPW" f...
package exiftool import ( "bufio" "bytes" "fmt" "io" "os/exec" "sync" "github.com/pkg/errors" ) // Stayopen abstracts running exiftool with `-stay_open` to greatly improve // performance. Remember to call Stayopen.Stop() to signal exiftool to shutdown // to avoid zombie perl processes type Stayopen struct { ...
package cooker import ( "fmt" "github.com/ProfessorMc/Recipe/spoilers/appliance" "github.com/ProfessorMc/Recipe/spoilers/dish" "sync" "time" ) type HeatOMatic struct { hasPower bool isOn bool currentTemp float32 busy bool mtx sync.Mutex } func NewHeatOMatic() *HeatOMatic { newHeatOMatic := &HeatOMatic{ }...
package pain import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document01800101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:pain.018.001.01 Document"` Message *MandateSuspensionRequestV01 `xml:"MndtSspnsnReq"` } func (d *Document0180010...
// Copyright (C) 2019 The Android Open Source Project // // 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 applica...
package irc import ( "strings" "time" "github.com/goshuirc/irc-go/ircmsg" "github.com/goshuirc/irc-go/ircutils" "awesome-dragon.science/go/goGoGameBot/pkg/event" "awesome-dragon.science/go/goGoGameBot/pkg/util" ) // RawEvent represents an incoming raw IRC Line that needs to be handled type RawEvent struct { ...
package main import "fmt" type OffsetWidget int func (widget OffsetWidget) sizeForLayout(layout Layout) Size { if layout.pressure > 3 { return Size{0, 0} } height := 2 width := 20 if layout.show_date { height = 4 } return Size{width, height} } func (widget OffsetWidget) drawAtPoint(tab *DataTab, layout L...
// Copyright 2021 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applica...
// 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 raw_client import "context" type DeletePreviewAppFormFieldsRequest struct { App string `json:"app"` Fields []string `json:"fields"` Revision string `json:"revision,omitempty"` } type DeletePreviewAppFormFieldsResponse struct { Revision string `json:"revision"` } func DeletePreviewAppFormField...
package main import ( "fmt" "os" "github.com/shirou/gopsutil/process" ) var ps *process.Process func men(n int) { if ps == nil { p, err := process.NewProcess(int32(os.Getpid())) if err != nil { panic(err) } ps = p } m, _ := ps.MemoryInfoEx() fmt.Printf("%d. VMS: %d MB, RSS: %d MB\n", n, m.VMS>>20,...
package components import ( "encoding/json" "net/http" "time" "github.com/dgrijalva/jwt-go" ) type jsonError struct { Error string `json:"error"` } //JSONError Helper function to return restful errors func JSONError(response http.ResponseWriter, errorString string, statusCode int) { errorJSONString, _ := jso...
package main import ( "fmt" ) //DECLARE that the variable with the IDENTIFIER "Z" is od TYPE int var z = 42 func main() { fmt.Println(z) }
// // Copyright (c) 2017 Intel Corporation // // 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...
package leetcode // HasDuplicates checks whether the slice has duplicates func HasDuplicates(numbers []int) bool { hash := map[int]int{} for i := 0; i < len(numbers); i++ { if _, ok := hash[numbers[i]]; !ok { hash[numbers[i]] = hash[numbers[i]] + 1 } else { return true } } return false }
package bitmask type Bitmask uint32 func (f Bitmask) HasFlag(flag Bitmask) bool { return f&flag != 0 } func (f *Bitmask) AddFlag(flag Bitmask) { *f |= flag } func (f *Bitmask) ClearFlag(flag Bitmask) { *f &= ^flag } func (f *Bitmask) ToggleFlag(flag Bitmask) { *f ^= flag }
package leetcode import ( "bytes" "container/list" "fmt" ) //TODO 自实现双向链表 type kv struct { k, v int } // LRUCache 最近最少使用缓存 type LRUCache struct { hash map[int]*list.Element data *list.List len int cap int } // Constructor 初始化 func Constructor(capacity int) LRUCache { return LRUCache{hash: map[int]*list....
package suites import ( "testing" "github.com/go-rod/rod" ) func (rs *RodSession) verifyMailNotificationDisplayed(t *testing.T, page *rod.Page) { rs.verifyNotificationDisplayed(t, page, "An email has been sent to your address to complete the process.") }
package nsmanager_test import( "testing" "manager/nsmanager" //"stockdb" //"fmt" ) func Test_NSMfgPmiManager_Process(t *testing.T){ m := nsmanager.NewNSMfgPmiManager() m.Process() }
package service import ( "gopetstore/src/domain" "gopetstore/src/persistence" "log" "sync" ) const orderNum = "ordernum" // get order by order id func GetOrderByOrderId(orderId int) (*domain.Order, error) { o, err := persistence.GetOrderByOrderId(orderId) if err != nil { return nil, err } o.LineItems, err ...
package main func test() { var a int defer func() { if p := recover(); p != nil { a = 1111 } }() panic(2222) print(a) } func main() { test() }
package status import ( "encoding/json" "io/ioutil" "os" "path/filepath" "regexp" "strings" "github.com/devspace-cloud/devspace/pkg/util/factory" "github.com/devspace-cloud/devspace/pkg/util/log" "github.com/devspace-cloud/devspace/pkg/util/message" "github.com/pkg/errors" "github.com/spf13/cobra" ) var ...
package fastsort import ( . "leetcode_notes/utils/linkedlist" ) // func LinkedListFastSort1(l *IntListNode) *IntListNode { head := l linkedListFastSort1(head, nil) return head } func linkedListFastSort1(head, end *IntListNode) { if head == nil || head == end { return } p := head.Next // pointer for run sma...
package medianheap_test import ( . "math" "math/rand" "reflect" "sort" "testing" "time" . "github.com/pietv/medianheap" ) var Tests = []struct { name string in []int want []int }{ {"1", []int{0}, []int{0}}, {"2", []int{MaxInt32}, []int{MaxInt32}}, {"3", []int{MinInt32}, []int{MinInt32}}, {"4", []int...
//go:build !fast // +build !fast // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. package helpers const ( // SSHKeySize is the size (in bytes) of SSH key to create SSHKeySize = 4096 // DefaultPkiKeySize is the default size in bytes of the PKI key DefaultPkiKeySize ...
// Package fakefs contains fake implementations of interfaces from package io/fs // from the standard library. // // It is recommended to fill all methods that shouldn't be called with: // // panic("not implemented") // // in the body of the test, so that if the method is called the panic backtrace // points to the met...
package ionic import ( "bytes" "encoding/json" "fmt" "github.com/ion-channel/ionic/pagination" "net/url" "time" "github.com/ion-channel/ionic/community" "github.com/ion-channel/ionic/dependencies" "github.com/ion-channel/ionic/products" "github.com/ion-channel/ionic/responses" "github.com/ion-channel/ionic...
package main //import "time" const OVERKILL_DAMAGE = 5 type OnKillCallback func(u *BaseCharacter) FList type BaseCharacter struct { Object *Object Killed bool HP float64 onKill OnKillCallback MaxHP float64 CurrentSkill *SkillUsing } type SkillUsing struct { startIteration uint3...
// Copyright 2023 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 ( "encoding/json" "fmt" "io" "log" "net/http" "os" "strings" "github.com/gorilla/mux" ) type Gpx = struct { Name string Date string Description string Track_points [][]float64 } func Map(input [][]float64, f func([]float64) string) []string { result := make([]string...
/* * @Description: * @Author: JiaYe * @Date: 2021-04-12 15:30:12 * @LastEditTime: 2021-04-12 16:03:44 * @LastEditors: JiaYe * @Descripttion: * @version: */ package main import "fmt" //定义结构体Dog type Dog struct { name string } func (dog Dog) call() { fmt.Printf("%s: 汪汪\n", dog.name) } ...
package main import ( "fmt" "log" "net" "os" "os/signal" i "puppet_monitoring/impl" "puppet_monitoring/rpc" "runtime" "strconv" "syscall" ) // global variable (load once) var settings = i.Settings{}.LoadSettings() // runs master process func run_master_process() { log.Printf("PID:%v\n", os.Getpid()) //...
package main import ( "encoding/json" "net/http" "strconv" auth "github.com/ahmedash95/authSDK" "github.com/gorilla/mux" ) func GetPostComments(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) postID := vars["id"] var comments []Comment GetDB().Where("post_id = ?", postID).Find(&comments) js...
package problem0354 func maxEnvelopes(envelopes [][]int) int { if len(envelopes) <= 1 { return len(envelopes) } quickSort(envelopes) dolls := []int{envelopes[0][1]} for i := 1; i < len(envelopes); i++ { num := envelopes[i][1] if num > dolls[len(dolls)-1] { dolls = append(dolls, num) } else { pos := ...
// Copyright 2017 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 token type TokenService struct { }
package utils import ( "bytes" "encoding/hex" "io" "log" "math" "math/rand" "mime/multipart" "os" "strconv" "strings" "time" ) /** * 初始化一下种子 */ func RandomInit() { rand.Seed(time.Now().UnixNano()) } func Random(min, max int64) int64 { if min == max { return min } //rand.Seed(time.Now().UnixNano()...
package pubsubprovider import ( "context" "encoding/json" "sync" "time" "cloud.google.com/go/pubsub" "go-gcs/src/logger" "go-gcs/src/service/googlecloud" "go-gcs/src/service/googlecloud/storageprovider" "google.golang.org/api/option" ) // PubSub is the structure for config type PubSub struct { Topic ...
/* Copyright 2021 CodeNotary, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to i...
package handler import ( "context" "errors" "time" "fmt" crypto "github.com/jinmukeji/go-pkg/v2/crypto/encrypt/legacy" "github.com/jinmukeji/go-pkg/v2/crypto/rand" "github.com/jinmukeji/jiujiantang-services/jinmuid/mysqldb" proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/user/v1" ) const ( ...
package sys func init() { FixConsole() }
package handler import "simple-calculator/internal/utils" func CalHandler(exp string) int { //调用计算工具进行计算 result := utils.Calculator(exp) return result }
package main import "fmt" //标识符:变量名 函数名 类型名 方法名 //go语言中如果标识符首字母是大写的,就表示对外部包可见 // Dog 首字母大写需要添加注释 type Dog struct { name string gender string } //构造函数 func newDog(name string, gender string) dog { return dog{ name: name, gender: gender, } } //方法是作用于特定类型的函数 //接受者表示的是调用该方法的具体类型变量,多用于类型名首字母小写表示 func (d dog)...
package main import ( "fmt" ) type myType int func (t myType) setByValue(nval myType) { t = nval } func (t *myType) setByPtr(nval myType) { *t = nval } func main() { var x myType = 0 x.setByValue(1) fmt.Println(x) x.setByPtr(2) fmt.Println(x) }
package goproxy import ( "context" "io" ) // RevInfo describes a single revision of a module source type RevInfo struct { Version string // version string Time string // commit time // These fields are used for Stat of arbitrary rev, // but they are not recorded when talking about module versions. Name st...
package montecarlo import ( "fmt" "math" "testing" log "github.com/Sirupsen/logrus" assert "github.com/stretchr/testify/assert" ) /*-------- TEST INPUTS & SETUP --------*/ var normal, nodeWithChildren, nodeWithGrandchildren Node func nodeTestSetup() { var err error normal, err = NewNode(1) if err != nil { ...
package double_pointer // RemoveElement 删除所有值为val的元素 func RemoveElement(nums []int, val int) []int { fast, slow := 0, 0 for fast < len(nums) { if nums[fast] != val { nums[slow] = nums[fast] slow++ } fast++ } return nums[:slow] }
package main import ( "fmt" "strconv" "strings" ) func strToIntArr(str string) (result []int) { var k int arrStr := strings.Split(str, ",") for _, each := range arrStr { k, _ = strconv.Atoi(each) result = append(result, k) } return } func findMajority(arr []int) (result int, found bool) { limit := len(a...
package mocks import ( "io" "strings" ) var _ io.WriteCloser = &BuildCloser{} type BuildCloser struct { strings.Builder } func (b *BuildCloser) Close() error { return nil } func NewBuildCloser() *BuildCloser { return &BuildCloser{strings.Builder{}} }
package runner import ( "evier/config" "evier/integrations" "time" ) func Run(cfg config.Config) (e error) { rsyncOptions := cfg.Rsync intgs := integrations.IntegrationGroup{cfg.Integrations} startTime := time.Now() intgs.NotifyProcessStart(startTime) for _, job := range cfg.Jobs { jobStart := time.Now() ...
package main import ( "encoding/json" "fmt" ) type MultiInvoiceResultQueryPostData struct { Pch string `json:"pch"` } func FlowMultiInvoiceResultQuery(PchNumber string) string{ multiInvoiceResultQueryPostData := MultiInvoiceCheckPostData{} multiInvoiceResultQueryPostData.Pch = PchNumber multiInvoiceResultQuer...
// 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...
// Copyright 2021 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applica...
package Problem0134 func canCompleteCircuit(gas []int, cost []int) int { remains, debts, start := 0, 0, 0 for i, g := range gas { remains += g - cost[i] if remains < 0 { // i + 1 处重新开始 start = i + 1 // 记录沿路一共欠缺的油量 debts += remains // remain 至零 remains = 0 } } if debts+remains < 0 { // 最...
package builtins import ( "os" "path/filepath" ) type fileClass struct { valueStub } func NewFileClass() Value { f := &fileClass{} f.initialize() f.class = NewClassValue() // FIXME: this should be a global reference f.AddMethod(NewMethod("expand_path", func(args ...Value) (Value, error) { arg1 := args[0].(*...
//source: https://github.com/ftylitak/qzxing/tree/master/examples/QZXingLive package main import ( "os" "github.com/therecipe/qt/core" "github.com/therecipe/qt/gui" "github.com/therecipe/qt/internal/examples/3rdparty/qzxing" ) func main() { // enable high dpi scaling // useful for devices wi...
package resources import ( "fmt" v2 "github.com/envoyproxy/go-control-plane/envoy/api/v2" "github.com/envoyproxy/go-control-plane/envoy/api/v2/route" ) // MakeRoute creates an HTTP route that routes to a given cluster. //type clusterName string //type routeConfig struct{ // clusterName []string, // domains []stri...
package main import ( "fmt" "math" ) type Shape interface { area() float64 perimeter() float64 } type Rect struct { width, height float64 } type Circle struct { radius float64 } //Rect 타입에 대한 Shape 인터페이스 구현 func (r Rect) area() float64 { return r.width * r.height } func (r Rect) perimeter() float64 { re...
package common type Service interface { Stop() }
// Copyright © 2017 Aeneas Rekkas <aeneas+oss@aeneas.io> // // 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 appl...
package config import ( "testing" "fmt" ) func Test_readXml(t *testing.T) { const result = `map[server>address:127.0.0.1 server>port:8080 log>file>name:log.log log>file>size:1024]` readXml(configMap, `example.xml`) if fmt.Sprintf("%s", configMap) != result { t.Error(fmt.Sprintf("%s", configMap), " \nNot Equal...
package main import ( "flag" "fmt" "log" "os" "github.com/tada3/triton/tritondb" "github.com/tada3/triton/weather/owm" ) const () var ( clearFlag bool ) func main() { log.Println("Triton Admin Tool") flag.Usage = func() { fmt.Fprintln(os.Stderr, "Usage:\n att [--clear] <filepath>") } flag.BoolVar(&c...
package stages import ( "encoding/json" "fmt" "os" "path/filepath" "github.com/hashicorp/terraform-exec/tfexec" "github.com/pkg/errors" "github.com/openshift/installer/pkg/terraform" "github.com/openshift/installer/pkg/terraform/providers" "github.com/openshift/installer/pkg/types" ) // StageOption is an o...
package models import ( "fmt" "contoh_mvc/database" ) type Siswa struct { Id int `json:"id"` Nama string `json:"nama"` Kelas string `json:"kelas"` } // method untuk inisialisasi model siswa baru func NewSiswaModel() Siswa { return Siswa{} } func (s *Siswa) SetId(id int) { s.Id = id; } func (s *Siswa)...
package mcbanner import ( "fmt" "testing" "github.com/google/uuid" "github.com/stretchr/testify/assert" ) func ExampleGetAddress() { status := ServerStatus{ Host: "example.com", Port: 25565, } fmt.Println(status.GetAddress()) status = ServerStatus{ Host: "example.com", Port: 25566, } fmt.Println(...
package leetcode func isPalindrome234(head *ListNode) bool { nums := make([]int, 0) for head != nil { nums = append(nums, head.Val) head = head.Next } for i, j := 0, len(nums)-1; i < j; i++ { if nums[i] != nums[j] { return false } j-- } return true }
package arrays /*ArraySum ... Function Specification: INPUTS: numbers = An array of integer values OUTPUTS: The sum of all the entries in the inputted array */ func ArraySum(numbers []int) int { var sum int for _, number := range numbers { sum += number } return sum } /*ArraySumAll ... Function Specification:...
package main //go:generate go run scripts/inline_schema.go
package corekit import ( "context" "encoding/json" "fmt" "log" "net/http" "os" "os/signal" "syscall" "time" "github.com/bmizerany/pat" "github.com/prometheus/client_golang/prometheus/promhttp" ) type Service interface { Get(path string, handler APIHandler) Post(path string, handler APIHandler) Put(path...
package Problem0290 import ( "strings" ) func wordPattern(pattern string, str string) bool { ps := strings.Split(pattern, "") ss := strings.Split(str, " ") if len(ps) != len(ss) { return false } return isMatch(ps, ss) && isMatch(ss, ps) } func isMatch(s1, s2 []string) bool { size := len(s1) m := make(ma...
package main import ( "fmt" "log" "net/http" "github.com/ITSecMedia/gfapigonnect" ) func queryGravityFormsAPI(w http.ResponseWriter, r *http.Request) { var gf API gf.BaseURL = "http://<wordpressblog_domain>/gravityformsapi/" gf.KeyPublic = "<public_key>" gf.KeyPrivate = "<private_key>" gfID := "<gf_form_i...
// Copyright (c) 2020 by meng. All rights reserved. // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. /** * @Author: meng * @Description: * @File: behavior_tree * @Version: 1.0.0 * @Date: 2020/4/10 15:28 */ package behavior_tree import ( "github.com/mx5...
package dht import ( "fmt" "net" "encoding/json" ) type Transport struct { bindAddress string msgQueue chan *Msg node *NODE } func (transport *Transport) listen() { udpAddr, err := net.ResolveUDPAddr("udp", transport.bindAddress) conn, err := net.ListenUDP("udp", udpAddr) conn.SetReadBuffer(10000)...
package mascot_test import ( "testing" "github.com/Akim-Delli/landGo/mascot" ) func TestMascot(t *testing.T) { if mascot.BestMascot() != "Tux" { t.Fatal("Go Gopher") } }
package main import ( "fmt" "github.com/ermos/hue" "log" ) func main() { bridge := hue.Conn("192.168.1.2", hue.BridgeOptions{ SaveToken: true, SaveLocation: "./", Debug: hue.DebugAll, }) err := bridge.Fetch.Bridge() if err != nil { log.Fatal(err) } fmt.Println(bridge.Config.Name) }
package trial import ( "io" "regexp" "testing" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) type mockReader struct { mock.Mock } func (reader *mockReader) Read(p []byte) (int, error) { returns := reader.Mock.Called(p) n := copy(p, returns.String(0)) return n, returns.Error(1)...
package errorDispose import "fmt" func ErrorPrint(error error, errorText string) { if error != nil { fmt.Println(error, errorText) return } }
package rpc import ( "net/http" "net/http/httptest" "testing" hTest "github.com/skos-ninja/truelayer-tech/lib/http/test" "github.com/skos-ninja/truelayer-tech/svc/pokemon/app/test" "github.com/gin-gonic/gin" "github.com/stretchr/testify/assert" ) func TestGetPokemonNoID(t *testing.T) { app := test.New(fals...
package main import ( "log" "net/http" "os" ) func main() { port := os.Getenv("PORT") log.Println("Listening...") err := http.ListenAndServe(":"+port, http.FileServer(http.Dir("public"))) if err != nil { log.Printf("Error running web server for static assets: %v", err) } }