blob_id stringlengths 40 40 | content_id stringlengths 40 40 | repo_name stringlengths 5 114 | path stringlengths 5 318 | language stringclasses 5
values | extension stringclasses 12
values | length_bytes int64 200 200k | license_type stringclasses 2
values | content stringlengths 143 200k |
|---|---|---|---|---|---|---|---|---|
2bdcdb53c2458db2ef6afbdaa0079993f9ed15e7 | bccb2dbf4f6fc90c6110719138f29899dd6bdbfe | lukedirtwalker/quic-go | /internal/crypto/null_aead_fnv128a_test.go | Go | go | 1,990 | permissive | package crypto
import (
"github.com/lukedirtwalker/quic-go/internal/protocol"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("NullAEAD using FNV128a", func() {
aad := []byte("All human beings are born free and equal in dignity and rights.")
plainText := []byte("They are endowed with rea... |
41b0f603e106af2b42925670ae7c14771e58e45d | 0b7adb65717745ed6784ca1737f2e5638757556c | Miguelmorales13/e-commerce-api-client-go | /entities/users.model.go | Go | go | 1,033 | no_license | package entities
import (
"gorm.io/gorm"
"time"
)
type User struct {
ID uint ` gorm:"not null;primaryKey;auto_increment" json:"id"`
Name string `validate:"required" gorm:"not null" json:"name"`
LastName string `validate:"required" gorm:"not null" json:"lastNa... |
b86b0fd11433bdf750ffbfcde881389c69af62a7 | c141adbd253dc162c84f62b355c13518f9c9fdb1 | cgl22/go-demo | /src/main/ConditionStatement.go | Go | go | 1,301 | no_license | package main
import "fmt"
func main() {
// if
var age int = 18
if age == 18 {
fmt.Println("age为18")
} else {
fmt.Println("age不为18")
}
// switch
var score int = 80
switch score {
case 60, 65:
// 多个条件以逗号分隔
fmt.Println("及格")
case 70:
fmt.Println("一般")
case 80:
fmt.Println("良好")
case 90:
fmt.Pr... |
6dcb9f6c146011068571814c83b49306ce58b5db | 05fbb696d8d23de2fde9e9f3ccd516632b4e2326 | ftlnetwork/ftlnetwork-sdk | /cmd/ftlnetwork-sdk-cli/cmd/root.go | Go | go | 294 | permissive | package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "ftlnetwork-sdk-cli",
Short: "Tools to develop on ftlnetwork-sdk",
}
// Execute the command
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
|
bccc513d61a59d3f0b5e05a3d64ae8ac41379e01 | 53b4d4699e140d1072e867c0c274fc345a8e3db4 | galenguyer/reg | /tags_test.go | Go | go | 341 | permissive | package main
import (
"fmt"
"strings"
"testing"
)
func TestTags(t *testing.T) {
out, err := run("tags", fmt.Sprintf("%s/busybox", domain))
if err != nil {
t.Fatalf("output: %s, error: %v", out, err)
}
expected := `glibc
latest
musl
`
if !strings.HasSuffix(out, expected) {
t.Fatalf("expected: %s\ngot: %s",... |
ebaf503075380c3d0b4c94c79580b05015865e34 | bcd21b6e64b46f5de6eaefc43d5db50e8cc9dace | ecadlabs/signatory | /integration_test/vault_gcp_test.go | Go | go | 1,511 | permissive | package integrationtest
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGCPVault(t *testing.T) {
project := os.Getenv("VAULT_GCP_PROJECTID")
location := os.Getenv("VAULT_GCP_LOCATION")
keyring := os.Getenv("VAULT_GCP_KEYRING")
tz3 := os.Getenv("V... |
141493131be8859dc6338ce167e36caa1bbc2f73 | beca1d9aec6d2559250f4a66d61df6186d3cd957 | guitmz/ptrace | /sigclear.go | Go | go | 322 | no_license | package ptrace
// #cgo CFLAGS: -std=c99
// #include <stdlib.h>
// #include "clearsig.h"
import "C"
import(
"fmt"
)
func clear_signals(pid int) error {
errno := C.clearsignal(C.long(pid))
errnum := int(errno)
if errnum != 0 {
return fmt.Errorf("could not clear signals, err=%d\n", errnum)
}
return nil
... |
ad3ad3a2b1cdd860e80db4ac8d49e8e1d4932d03 | 4233e0b61df8687a81d74ef32c756ca9799e6c1f | yang-zhang-arch/gin-supermarket | /controller/UserController.go | Go | go | 2,471 | no_license | package controller
import (
"WebFull/common"
"WebFull/dto"
"WebFull/model"
"WebFull/response"
"WebFull/util"
"net/http"
"golang.org/x/crypto/bcrypt"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
)
func Register(cont *gin.Context) {
// 获取数据库实例
db := common.GetDB()
// 获取数据
var requestUser = model.U... |
81b671fccb37b05975bc10ebbf287704755ab14c | 306a4537fae0032d90d1231254dbb2e4a853ac60 | hmzzrcs/zebra | /router/route_sql.go | Go | go | 7,530 | no_license | package router
import (
"github.com/deckarep/golang-set"
_ "github.com/go-sql-driver/mysql"
"github.com/go-xorm/xorm"
log "github.com/sirupsen/logrus"
"github.com/tietang/go-utils"
"github.com/tietang/props/kvs"
"github.com/tietang/zebra/health"
"time"
)
const (
SQL_DRIVERNAME ... |
458e54935dfbe19be922e99aa9feff2e7f6a2373 | 01d37483e388c02b835de615459425fb21cd3656 | wharpreet/golangtutorials | /switch_statements/no_expression/main.go | Go | go | 453 | no_license | package main
import "fmt"
func main() {
MyFriendsName := ""
switch {
case len(MyFriendsName) == 2:
fmt.Println("Wassup my friend with name of length 2")
case MyFriendsName == "Test":
fmt.Println("Wassup Test")
case MyFriendsName == "Best":
fmt.Println("Wassup Best")
case MyFriendsName == "Appu", MyFriends... |
c2fb3ecdea8c7d9cd8810fd3ddf5d4efd9280317 | 12c00716b31a94623f54b897fb963003532900da | venturasr/test-infra | /development/tools/jobs/incubator/compass/compass_integration_test.go | Go | go | 5,709 | permissive | package compass_test
import (
"testing"
"github.com/kyma-project/test-infra/development/tools/jobs/tester"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const compassIntegrationTestJobPath = "./../../../../../prow/jobs/incubator/compass/compass-integration.yaml"
func TestCompassIn... |
e22f194c237ac6c006bac16fc1b3c5b0cf6927b9 | d3397410c32b64c8e4b125ea6ff0afd87b01e3e2 | ztxmao/vii | /library/data_class/cache/cache.go | Go | go | 33,708 | permissive | package cache
import (
"encoding/gob"
"fmt"
"io"
"os"
"runtime"
"sync"
"time"
)
import (
"github.com/emirpasic/gods/lists/doublylinkedlist"
)
type Item struct {
Object interface{}
Expiration int64
DataType string
}
// Returns true if the item has expired.
func (item Item) Expired() bool {
if item.E... |
551baca31863b1e988792ed0e1856f2b2feecae7 | c401c28509f7f58ea5bbd436144e43128abacfd9 | rob-aslanian/go-microservices | /user/pkg/profile/education.go | Go | go | 2,066 | no_license | package profile
import (
"time"
"github.com/globalsign/mgo/bson"
"gitlab.lan/Rightnao-site/microservices/user/pkg/internal/location"
"gitlab.lan/Rightnao-site/microservices/user/pkg/internal/users-errors"
)
// Education ...
type Education struct {
ID bson.ObjectId `bson:"id"`
School ... |
bf48978f6b7e547b298ff8ffeca611cce59d567b | 50bc5cfee32c4e54e669189a58766d4c59feb38e | ffacp/seiso | /pkg/kubernetes/clients.go | Go | go | 857 | permissive | package kubernetes
import (
"k8s.io/client-go/dynamic"
apps "k8s.io/client-go/kubernetes/typed/apps/v1"
batch "k8s.io/client-go/kubernetes/typed/batch/v1beta1"
)
// NewAppsV1Client for current kubeconfig
func NewAppsV1Client() (*apps.AppsV1Client, error) {
restConfig, err := RestConfig()
if err != nil {
return... |
1b76dbe8bebb22b129b7b066a77535c7c922d1a4 | b89d4c4741db867160ab6be3d4bf44c53d2535e5 | codeclimate/test-reporter | /vendor/github.com/spf13/cobra/cobra/cmd/add.go | Go | go | 3,496 | permissive | // Copyright © 2015 Steve Francia <spf@spf13.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 or... |
5b706c1b6bc751a0c1fe56316ccf4507b11a7a4e | a3eb91f90d9cd0427170abfe45fe0bd56c956f6b | davidae/smpl-msg | /client.go | Go | go | 3,751 | permissive | package smplmsg
import (
"crypto/rand"
"io"
"time"
"github.com/pkg/errors"
"github.com/streadway/amqp"
)
// DeliveryMode is the type of MIME type used to delivery of messages
type DeliveryMode uint8
// ContentType is the type of MIME type used for the content of the messages
type ContentType string
const (
/... |
c34d1aaf83d0ee3ae4b148db298bf66269ec9f6d | 6e8e9167cd1fbceba2a237f5d2810219916f3cbf | kubernetes/kube-state-metrics | /pkg/customresourcestate/config_metrics_types.go | Go | go | 3,033 | permissive | /*
Copyright 2021 The Kubernetes Authors 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 ag... |
ae16a62d2dd9419b80c5b48d8b47b7530191f603 | efbce95d203db5d671cba6fadeb1427a76f0cb63 | arunkbharathan/EPI | /Primitive_Type/palindrome/palindrome_test.go | Go | go | 351 | permissive | package palindrome
import (
"testing"
)
var testset = []struct {
x int
y bool
}{
{314, false},
{111, true},
{17871, true},
{123321, true},
{123421, false},
}
func TestPalindrome(t *testing.T) {
for _, aset := range testset {
y := palindrome(aset.x)
if aset.y != y {
t.Errorf("Expected %v got %v for %v... |
c01c431243c026a29847328961f6aed1b2bcaae5 | 81ccffa4e0d80cc23fe3d0ddbd3882e2121448c1 | alanyuen/xcgui | /xc/dateTime.go | Go | go | 3,857 | no_license | package xc
import (
"syscall"
"unsafe"
)
var (
// Functions
xDateTime_Create *syscall.Proc
xDateTime_SetStyle *syscall.Proc
xDateTime_GetStyle *syscall.Proc
xDateTime_GetButton *syscall.Proc
xDateTime_GetSelBkColor *syscall.Proc
xDateTime_SetSelBkColor *syscall.Proc
xDateTime_GetDate ... |
7643f9b9419b9b8356bfeba52a4f84e21c5177e9 | fd0e831d481563556939c87709524aa75ddf1a94 | rickwierenga/euler | /041.go | Go | go | 686 | no_license | package main
import (
"fmt"
"math"
)
func isPrime(x int) bool {
for i := 2; i < int(math.Sqrt(float64(x))) + 1; i++ {
if x % i == 0 {
return false
}
}
return true
}
func isPandigital(n int) bool {
seen := map[int]bool{}
l := int(math.Log10(float64(n))) + 1
for n > 0 {
if seen[n%10] ... |
44b87b3691b0ce69802afdf8f453374041ba1bfa | 1d03b56994b1f638cb9f21c2b18a15f0558cdae4 | rudyredhat/go_GetProgrammingWithGo | /11-Slices/04/trim_space.go | Go | go | 600 | no_license | // use of strings.TrimSpace and strings.Join using slice
package main
import (
"fmt"
"strings"
)
// Both worlds and planets are slices, and though worlds is a copy,
// they both point to the same underlying array.
func hyperspace(worlds []string) {
for i := range worlds {
worlds[i] = strings.TrimSpace(worlds[i])... |
b0fbb93091966d3c14b71a5a2a14fc442d8f3e59 | d34d577c2a6d023eee804d2840d440c7d83dc470 | hgsigner/stringfy | /underscore_test.go | Go | go | 603 | permissive | package stringfy_test
import (
"testing"
"github.com/hgsigner/stringfy"
)
func Test_Undercore(t *testing.T) {
tests := []struct {
in, out string
}{
{in: " Fizz ", out: "fizz"},
{in: "Fizz", out: "fizz"},
{in: "Fizz Buzz", out: "fizz_buzz"},
{in: "fizz_buzz", out: "fizz_buzz"},
{in: "Fázz Bôzz"... |
ac1f2d3eaa3b14bc741a765507cfbf3362e7ce24 | a03b2075d3b2dc2441fd589344f415b45b24d4a1 | yaohong/js_oss | /src/oss/main.go | Go | go | 851 | no_license | package main
import (
"net/http"
// "log"
"log"
"fmt"
)
var gTableMgr *TableMgr = nil
func CreateTableMgr() {
if gTableMgr == nil {
gTableMgr = NewTableMgr()
}
}
func main() {
CreateTableMgr()
err := gTableMgr.Init()
if err != nil {
log.Printf("tableMgr init failed, %v", err)
return
}
err = gTable... |
5f4f1472fa6839b4187a4feb4090ec15629f6d6e | c3861bdc37b97b704a3c352b724ca3e964e364c3 | jakubikan/skipper | /secrets/encrypter_test.go | Go | go | 2,245 | permissive | package secrets
import (
"fmt"
"os"
"reflect"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
type testingSecretSource struct {
getCount int
secretKey string
}
func (s *testingSecretSource) GetSecret() ([][]byte, error) {
s.getCount++
return [][]byte{[]byte(s.secretKey)}, nil
}
func TestEncryptD... |
e90e9b893a0d90fa2d07d9688b76b705e9dc0cb2 | 14350986e71c165d2066b8d659283b48ea2f8245 | biodranik/hugo | /resource/image_cache.go | Go | go | 2,773 | permissive | // Copyright 2017-present The Hugo Authors. 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 app... |
e64be90c11ec94fe35d506e14e81765af6e79425 | 545cab5fd44b86c8d06368de0652df1064988c3c | praneetb/golang | /plgin/config/config.go | Go | go | 2,814 | permissive | package config
import (
"fmt"
"log"
"io/ioutil"
"plugin"
"strings"
"github.com/go-ini/ini"
)
type DefaultConfig struct {
QueueLockTime int
MsgIndexString string
MasterElection bool
EtcdServers string
}
type PluginConfig struct {
PluginDirectory string
WatchDirectory string
Func... |
bd0b4529c683abf97a5179ff1c448463572e8801 | a1571c41c85d8d90fee082e3c097250a28702632 | saisuresh-banc91/temporal | /service/frontend/adminHandler_test.go | Go | go | 17,856 | permissive | // The MIT License
//
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
//
// Copyright (c) 2020 Uber Technologies, Inc.
//
// 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 Soft... |
8568cfa0370661ef869b7a723cf26cd33a28d946 | a53e8ea6f4eecabee68c27dcfbd1f452aa08530c | vinted/PromHouse | /vendor/github.com/kshvakov/clickhouse/clickhouse.go | Go | go | 7,218 | permissive | package clickhouse
import (
"bufio"
"context"
"database/sql"
"database/sql/driver"
"errors"
"fmt"
"net"
"reflect"
"regexp"
"sync"
"time"
"github.com/kshvakov/clickhouse/lib/binary"
"github.com/kshvakov/clickhouse/lib/column"
"github.com/kshvakov/clickhouse/lib/data"
"github.com/kshvakov/clickhouse/lib/... |
b4c745bc40460017595ce06d422e454985ab0ecd | 81757d800c3bcca6c8323110234f8dfb9a501a32 | Happy-Ferret/go-keyboardemulator | /keyboardemulator/keys_windows.go | Go | go | 7,948 | permissive | package keyboardemulator
import "github.com/AllenDang/w32"
// Missing virtual keys from w32 package
const (
Vk0 = 0x30
Vk1 = 0x31
Vk2 = 0x32
Vk3 = 0x33
Vk4 = 0x34
Vk5 = 0x35
Vk6 = 0x36
Vk7 = 0x37
Vk8 = 0x38
Vk9 = 0x39
VkA = 0x41
VkB = 0x42
VkC = 0x43
VkD = 0x44
VkE = 0x45
VkF = 0x46
VkG = 0x47
VkH =... |
ae781f224f0d5e87c35792306cb0a2a8f43c994b | 09c628f1d283163f1ee88c4590147e5c326dcad1 | kierdavis/gosound | /music/note.go | Go | go | 1,475 | no_license | package music
import (
"fmt"
"math"
)
type NoteLetter int
const (
C NoteLetter = iota
CSharp
D
DSharp
E
F
FSharp
G
GSharp
A
ASharp
B
DFlat = CSharp
EFlat = DSharp
GFlat = FSharp
AFlat = GSharp
BFlat = ASharp
)
func (letter NoteLetter) String() string {
switch letter {
case C:
return "C"
cas... |
30b27f9a6d4932911c76e8a28834c7489d148703 | 4d9b78765b93c12cb4745420d5b04a435b74ddf0 | sshyran/cloudfoundry-cli | /plugin_examples/call_cli_cmd/main/main_suite_test.go | Go | go | 294 | permissive | package main_test
import (
"code.cloudfoundry.org/cli/testhelpers/pluginbuilder"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestMain(t *testing.T) {
RegisterFailHandler(Fail)
pluginbuilder.BuildTestBinary(".", "call_cli_cmd")
RunSpecs(t, "Main Suite")
}
|
a43f22233bca829eb6afa3103efeffac3ebcd8a5 | ab080b36c10a9bca330dca70e7678c44bf118e18 | graeme-hill/gnet | /sys/filestore/in_memory.go | Go | go | 1,231 | no_license | package filestore
import (
"bytes"
"io"
"io/ioutil"
"github.com/pkg/errors"
)
var stores = map[string]map[string][]byte{}
// InMemFileStore just stores bytes in a map.
type inMemFileStore struct {
files map[string][]byte
}
// Read opens a reader on the file if it exists.
func (fs *inMemFileStore) Read(path st... |
0b1e0124c4d6b63936fa8160c3ff14950728b14b | ff6d750e52eeb1aab8d77f726ca52bff314489c5 | dathan/go-web-backend | /pkg/http/services/contacts/contacts.go | Go | go | 1,535 | no_license | package contacts
import (
"net/http"
"github.com/System-Glitch/goyave/v3"
"github.com/System-Glitch/goyave/v3/database"
"github.com/dathan/go-web-backend/pkg/entities"
localresponse "github.com/dathan/go-web-backend/pkg/http/response"
)
// List provides the full contact list TODO add pagination
func List(respon... |
b677eb8a31a773ef3db876903ce880bd3f53fedb | 9fcb71e0bcfa5bb1dcf2fac05396a400ff7beb8c | gophersgang/fibre | /context.go | Go | go | 10,369 | permissive | // Copyright © 2016 Abcum Ltd
//
// 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 ... |
075b968fe85d191ad3a72ec4e5b33c45826b1ecc | 0d80ef60c0c3061e8c31366bd9c2d00fb142f55c | svowl/go-core | /6-lesson/cmd/engine/main.go | Go | go | 5,014 | no_license | package main
import (
"bufio"
"fmt"
"log"
"os"
"strings"
"go-core/6-lesson/pkg/index"
"go-core/6-lesson/pkg/spider"
"go-core/6-lesson/pkg/storage"
"go-core/6-lesson/pkg/storage/file"
)
// Scanner это интерфейс, используется для тестирования
type Scanner interface {
Scan(string, int) (map[string]string, err... |
872404b05dd79247dfeab277a07bc894769fe9e8 | 59565c28c043b0a679565fb20a2abf291d387559 | philipwhen/movable-pledge | /pledge/apiserver_1.5/vendor/github.com/hyperledger/fabric/common/configtx/util.go | Go | go | 2,969 | permissive | /*
Copyright IBM Corp. 2017 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 ... |
a76b70db6d2209200f0816684425f9c748301849 | 1a3989bbaeda964cd4d6f1511c828a1322a061c6 | GoChallenge/GCSolutions | /march15/normal/bjoern-friese/decoder.go | Go | go | 3,061 | permissive | package drum
import (
"bytes"
"encoding/binary"
"fmt"
"io/ioutil"
"math"
"strings"
)
// DecodeFile decodes the drum machine file found at the provided path
// and returns a pointer to a parsed pattern which is the entry point to the
// rest of the data.
func DecodeFile(path string) (*Pattern, error) {
data, e... |
d219c2daeaff7da2a2f4c47d1ab5712937bb561a | 12e16808dd0d6ef7253b910070f7bd0026c788d3 | KunBetter/FundRec | /core/HotFund.go | Go | go | 831 | no_license | package core
import (
"encoding/json"
"fmt"
"github.com/KunBetter/FundRec/common"
"github.com/KunBetter/FundRec/entity"
"github.com/goinggo/mapstructure"
)
func (frc *FundRecCore) FetchHotFunds() {
frc.mysqlDB.AutoMigrate(&entity.Fund{})
rawRes := common.HttpGet(common.DXFundHotUrl)
if rawRes == "" {
retur... |
e394b70577c9f0f1845c85b0aea722b228698168 | 8795a5713b6be45f356b864c3fee8fc987e4437c | MrPotatoBobx/cordless | /tview/grid.go | Go | go | 19,224 | permissive | package tview
import (
"math"
"github.com/gdamore/tcell"
)
// gridItem represents one primitive and its possible position on a grid.
type gridItem struct {
Item Primitive // The item to be positioned. May be nil for an empty item.
Row, Column int // The top-left grid ... |
710333b81bdb833d4bdccaad4fe798674185c551 | 15cb5f3f06cc25f253bfb1e74bb330f14d7818ac | xuanjiang1985/go-examples | /tcp/serve1.go | Go | go | 611 | permissive | package main
import (
"bufio"
"io"
"net"
)
func main() {
ln, err := net.Listen("tcp", ":9000")
if err != nil {
panic(err)
}
defer ln.Close()
for {
conn, err := ln.Accept()
if err != nil {
panic(err)
}
// ---- first way
// for {
// bs := make([]byte, 1024)
// n, err := conn.Read(bs)
// ... |
d0f8962d06e1edef0fff8f711c69034df742f5a0 | 2d4834b92c7fa1305dbe83072335c7a981d475d0 | dulumao/boop | /runtime/function.go | Go | go | 265 | permissive | package runtime
import (
"github.com/Flaque/boop/parser"
)
type Function struct {
name string
args []string
guts parser.IFuncgutsContext
}
func NewFunc(name string, args []string, guts parser.IFuncgutsContext) Function {
return Function{name, args, guts}
}
|
6472f9ee4443d30648db588ffefd354bc6ba9680 | e948d8c96ee84670a2464ccf20c89aa45a67a6da | nibbles-on-bits/codewars-decode-the-morse-code-advanced | /main.go | Go | go | 3,589 | no_license | package main
import (
"fmt"
"strings"
)
func main() {
test := "1100110011001100000011000000111111001100111111001111110000000000000011001111110011111100111111000000110011001111110000001111110011001100000011"
fmt.Println(getWordsFromBitSentence(test))
}
//DecodeMorse will take a Morse encoded sentence in the form ... |
df2a5a57b838b91f512f548927ff9c4c22f79d69 | 02aa076074084d594f1593bde2ad39daa8a88ba9 | influx6/wordies | /vendor/github.com/influx6/faux/flags/flag.go | Go | go | 13,543 | permissive | // Package flags creates a augmentation on the native flags package.
package flags
import (
"bytes"
"context"
"flag"
"fmt"
"log"
"os"
"os/signal"
"strings"
"syscall"
"text/template"
"time"
"github.com/influx6/faux/bag"
)
const (
usageTml = `Usage: {{ toLower .Title}} [flags] [command]
⡿ COMMANDS:{{ ra... |
5079721e7bf88e0de2926cc0af2c5baa4ed4067b | 617dbaa9e6c4c8dfe29da5d5c4a2dc58ab1ce431 | AaronPei/k8s-controller-custom-resource | /main.go | Go | go | 1,814 | no_license | package main
import (
"flag"
"time"
"github.com/golang/glog"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
// Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters).
// _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
clientset "github.com/... |
b03e622f10c70176e0aa66cc1c2e50f734e6d215 | 7e3653b1a8a7e3b47f46182938a29065e1b928d4 | mcadam/dogutil | /const.go | Go | go | 477 | permissive | // Copyright (c) 2013-2014 The btcsuite developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package dogutil
const (
// SatoshiPerBitcent is the number of satoshi in one bitcoin cent.
SatoshiPerBitcent = 1e6
// SatoshiPerBitcoin is the number of satoshi in ... |
754a9d2097df7574690f4bec2fcf29bd4569f414 | b5aee24f80dcb17698df59f5062068e4d38c3ef4 | childe/healer | /heartbeat_response.go | Go | go | 765 | no_license | package healer
import (
"encoding/binary"
"fmt"
)
type HeartbeatResponse struct {
CorrelationID uint32
ErrorCode int16
}
func (r HeartbeatResponse) Error() error {
return getErrorFromErrorCode(r.ErrorCode)
}
func NewHeartbeatResponse(payload []byte) (r HeartbeatResponse, err error) {
offset := 0
response... |
130d31eb5e6eaab97d15d0e36646c5940f838666 | 80e184bdf9e2ab0b35963fe5cce9527c078f655d | RuNpiXelruN/user_roles | /.history/cmd/cli/root_20200810132601.go | Go | go | 1,050 | no_license | package cli
import (
"fmt"
"log"
"os"
"strings"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var userID string
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "DeputyTest\n",
Short: "\nDeputy tech challenge by Justin Davidson (justindavi... |
ad88808d36fce4df1f9bedef705a1eb11dc428be | f0e4008cd22a6dc298548ed0deb5857ad4a638e9 | whoisjeremylam/enu | /internal/github.com/btcsuite/btcd/btcjson/chainsvrwsntfns_test.go | Go | go | 7,663 | permissive | // Copyright (c) 2014 The btcsuite developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package btcjson_test
import (
"bytes"
"encoding/json"
"fmt"
"reflect"
"testing"
"github.com/whoisjeremylam/enu/internal/github.com/btcsuite/btcd/btcjson"
)
// TestCh... |
12d93e83f8fd55d363b663a609aa9d1ef4430117 | 72d369357026b55c35a61fd6a89898c69aebcecb | dandrushko/antrea | /test/e2e/antreapolicy_test.go | Go | go | 128,925 | permissive | // Copyright 2020 Antrea 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 ... |
99d7b56bbd1728325fae0df129d9d6687e8f461e | a3d6a88e7a20be47520769bb8ee7a1b8f0d4a721 | iawaknahc/jsonschema | /pkg/jsonschema/keyword_recursive_ref.go | Go | go | 1,829 | no_license | package jsonschema
import (
"fmt"
)
type RecursiveRef struct{}
var _ Keyword = RecursiveRef{}
func (_ RecursiveRef) Keyword() string {
return "$recursiveRef"
}
func (_ RecursiveRef) Apply(ctx ApplicationContext, input Node) (*Node, error) {
ref := input.Scope.Schema.JSONValue.(string)
if ref != "#" {
return ... |
2db1ca3bcd09066359109a94a1c2eae8d519367b | 7698f59cb96485af1871952d805ac288d3488eb0 | small-lei/peppercron | /dispatch/job_execution_test.go | Go | go | 1,090 | permissive | package dispatch
import (
"context"
"testing"
"time"
"github.com/huajiao-tv/peppercron/logic"
)
func TestJobExecution(t *testing.T) {
// create instance
ctx, stop := context.WithCancel(context.Background())
defer stop()
exec := NewJobExecution(ctx)
// subscribe
td := &TestDispatcher{
jobName: "TestJ... |
e4abb85d7273488be6aaeb6426569ccccf3c2cab | 1696650d59bbb965ca343e5e1f2e9c3ee7aecde7 | n4j/kata-containers | /src/runtime/virtcontainers/mount.go | Go | go | 14,514 | permissive | // Copyright (c) 2017 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
package virtcontainers
import (
"context"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"syscall"
merr "github.com/hashicorp/go-multierror"
"github.com/kata-containers/kata-containers/src/runtime/pkg/katautils/... |
ccfd707ece7fe57a96882498110a68851858c6a9 | 36f0fe8ddc656ab0c270ca9a9714cd6db36d613f | riccccchard/chaos-mesh | /test/e2e/chaos/basic.go | Go | go | 66,527 | permissive | // Copyright 2020 Chaos Mesh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... |
a911a91088e3bc2c34a3abb09301a1b8294bc1e2 | 3b6dd106f67ec8a70c4207a4b50a66288fd4f778 | pen-pal/podman | /pkg/domain/entities/containers.go | Go | go | 8,871 | permissive | package entities
import (
"io"
"net/url"
"os"
"time"
"github.com/containers/image/v5/types"
"github.com/containers/podman/v2/libpod/define"
"github.com/containers/podman/v2/pkg/specgen"
"github.com/cri-o/ocicni/pkg/ocicni"
)
// ContainerRunlabelOptions are the options to execute container-runlabel.
type Cont... |
673c450e7557e71006f991e782c680c2cab215dd | 538e4c41c58ccb91192d1d18ad4999f5c7b6f8ef | cergey-obr/review-go | /models/author.go | Go | go | 347 | no_license | package models
import "github.com/astaxie/beego/orm"
type Author struct {
Id int `orm:"auto;pk"`
Nickname string `orm:"size(128)"`
Email string `orm:"size(128);null;unique"`
CustomerId int `orm:"index;default(0)"`
Review []*Review `orm:"reverse(many)"`
}
func init() {
orm.R... |
f5805db4a33883198ccf5b40c1fcafd783d32b9e | ad57bf8bedceb7d281f0e9bf0f6e556423822250 | duanjunxiao/gowiki | /wiki.go | Go | go | 3,693 | no_license | package main
import (
"errors"
"fmt"
"io/ioutil"
"net/http"
"regexp"
"text/template"
"strings"
)
var templates = template.Must(template.ParseFiles("tmpl/edit.html", "tmpl/view.html"))
var validPath = regexp.MustCompile("^/(edit|view|save)/([a-zA-Z0-9]+)$")
var pageLink = regexp.MustCompile("\\[([a-zA-Z0-0]+)\\... |
36340e7fa04d4f2f1b94f5b5cf51c63a57f5cb0f | 281a3fdf663e5da5040c1d29a74d5345cf9c440a | csweichel/packer | /utils/csvBOM_to_packer.go | Go | go | 2,354 | permissive | // This utility takes the output of CSV BOM for Autodesk Fusion 360 (https://apps.autodesk.com/FUSION/en/Detail/Index?id=2857656002406992603&appLang=en&os=Mac)
// and transforms it into a JSON file that the packer CLI can work with.
//
// We assume that the smallest dimension is the material thickness.
package main
i... |
e8b3c5697a86316e90bfc64d8c718e4c61d19e0c | 9c77fe143fb7faf1ccd31cb68e7106f76b160ff4 | cuteshell/zroute | /route/driver/drivers/modbus/tcp/modbus.go | Go | go | 563 | permissive | package main
import (
"fmt"
"github.com/hashicorp/go-plugin"
"zroute.io/route/driver/common"
)
type ModbusTCP struct {
}
func (m *ModbusTCP) ReadPoints(req common.Request) (common.Response, error) {
var resp common.Response
fmt.Println("ReadPoints was called")
return resp, nil
}
func main() {
driver := &Mod... |
ac27eaec1f3bb7195fd2847e25bfb4e252635d2f | b4dc82968c550fd3b235ab80868cc32f5283995e | Birjemin/leetcode-go | /algorithms/0006-zigzag-conversion/zigzag-conversion_test.go | Go | go | 1,474 | no_license | package zigzag_conversion
import (
"github.com/stretchr/testify/assert"
"testing"
)
type param struct {
one string
two int
}
type result struct {
one string
}
type question struct {
p param
a result
}
func Test(t *testing.T) {
ast := assert.New(t)
qs := []question{
{
... |
d277dd6b9b314af4e0cd4b3d437b7c16687ba466 | 24a96d4d8405b3a66fdb0a2d564c72bf0dd2b007 | osmir-cds/istio | /istioctl/pkg/install/pre-check_test.go | Go | go | 5,546 | permissive | // Copyright 2019 Istio 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 ... |
c75f81483c5f9c26cbd365a4beb303bb39b2e6d5 | 94af653927d27eb7120c41b39fdd8ed568e6b76f | pethersonmoreno/secretvault | /controllers/secretGroup/drive/listDirectoriesDrive.go | Go | go | 1,652 | permissive | package drive
import (
"net/http"
"secretvault/googledrive"
"secretvault/io"
"github.com/gin-gonic/gin"
)
type GoogleDirectoryWithId struct {
Id string `json:"id"`
Title string `json:"title"`
}
func listDirectoriesDriveHandler(ctx *gin.Context) {
secretGroupId := ctx.Param("secretGroupId")
_, hasIntermed... |
5737e3fbba0b2a1346e4757bd4c64fd063cf816d | 32d13a0f24d4aef1e485ac52b63de0c28486d173 | Mattlk13/oci-go-sdk | /databasemigration/data_pump_job_mode.go | Go | go | 1,581 | permissive | // Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved.
// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose ei... |
ea4e2b215f7f63a9c9795f25c313f418f6c21b12 | 287ae4b39d826b360fdbc38985bd7ca1c6d05f53 | Mywanit/cloudflare-go | /cmd/flarectl/firewall.go | Go | go | 8,686 | permissive | package main
import (
"fmt"
"net"
"strconv"
"github.com/pkg/errors"
"github.com/cloudflare/cloudflare-go"
"github.com/urfave/cli"
)
func formatAccessRule(rule cloudflare.AccessRule) []string {
return []string{
rule.ID,
rule.Configuration.Value,
rule.Scope.Type,
rule.Mode,
rule.Notes,
}
}
func fir... |
68cd673e5a0c136ec8734ad1395fa195a8ba8077 | 32e60af87fee3c84d857c5ab0c3e80e134e14151 | mrlaojia/mcube | /cmd/mcube/templates/pkg/example.go | Go | go | 6,016 | permissive | package pkg
// ExampleHTTPObjTemplate todo
const ExampleHTTPObjTemplate = `package http
import (
"errors"
"github.com/infraboard/mcube/http/router"
"{{.PKG}}/client"
"{{.PKG}}/pkg"
"{{.PKG}}/pkg/example"
)
var (
api = &handler{}
)
type handler struct {
service example.ServiceClient
}
// Registry 注册HTTP服务路... |
5753eb99cb75c39880adb8cb978375940b98e49a | b2f07ac20782baf1aef082246329a4fa7c95cf23 | dpena1094/certmgr | /cert/util.go | Go | go | 3,043 | permissive | // Package cert contains certificate specifications and
// certificate-specific management.
package cert
import (
"bytes"
"crypto/ecdsa"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/json"
"encoding/pem"
"errors"
"fmt"
"net"
"sort"
"strings"
)
func displayName(name pkix.Name) string {
var ns []... |
cef7189eac93a5a6054325e9c70ac39984be2909 | 5192d75c33a504d6bfb53fedb60bd4c66fba5e5a | izayacity/Go_practice | /linkedList/problem2_4.go | Go | go | 490 | no_license | package linkedList
/*
2.4 Partition: Partition a linked list around a value x, such that all
nodes less than x come before all nodes greater than or equal to x.
If x is contained within the list, the values of x only need to be after
the elements less than x (see below). The partition element x can appear
anywhere in ... |
24b8475b875dc6860ae4e4c18f19c9a3e3991fcf | 00242341ad3b1d00da9261936c4f260448c82fef | laudarch/iso20022 | /camt/CustomerPaymentCancellationRequestV03.go | Go | go | 6,404 | permissive | package camt
import (
"encoding/xml"
"github.com/fgrid/iso20022"
)
type Document05500103 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:camt.055.001.03 Document"`
Message *CustomerPaymentCancellationRequestV03 `xml:"CstmrPmtCxlReq"`
}
func (d *Document05500103) AddMessage() *CustomerPaymentCance... |
abfdf8fb8db0aa2c5c96c32eed9fcc0e74cc6f99 | f8a8242c7990bdcb97845fd4d43424c20eb962ba | peace0phmind/gmf | /examples/fps-image.go | Go | go | 4,942 | permissive | package main
import (
"errors"
"flag"
"github.com/peace0phmind/gmf"
"io"
"log"
"runtime/debug"
"syscall"
//"syscall"
)
func fatal(err error) {
debug.PrintStack()
log.Fatal(err)
}
func assert(i interface{}, err error) interface{} {
if err != nil {
log.Fatal(err)
}
return i
}
func addStream(codecName... |
ff51f3da304e2ae439e1c6bff9d579eff50e97a5 | d2f8508c3d1938f12370b73520876c238c5cc624 | operator-playground/postgres-operator | /testing/pgo_cli/cluster_backup_test.go | Go | go | 10,046 | permissive | package pgo_cli_test
/*
Copyright 2020 Crunchy Data Solutions, 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 applica... |
ff8035af572d034553b9a75b03e02ba234d7f714 | 43b49191cf36288f20ba13930bdfc7df25ce4a58 | geezyx/kubebuilder | /testdata/project-v3-config/api/v1/admiral_webhook.go | Go | go | 1,516 | permissive | /*
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, ... |
c9f8850e0cdee3ff720d552e6bf89db584be973d | 40c194865e14bfd997e464cdc36575511629fbd5 | seizadi/atlas-contacts-app | /cmd/config.go | Go | go | 4,029 | permissive | package cmd
import (
"fmt"
"github.com/infobloxopen/atlas-contacts-app/cmd/setting"
"github.com/infobloxopen/atlas-contacts-app/db"
)
//const (
// // ServerAddress is the default address for the gRPC server, if no override is specified in the flags
// ServerAddress = "0.0.0.0:9090"
// // GatewayAddress is the defa... |
088d26cc00f70dfc06078cc3288a9222a4799950 | d27a55516aafdcdc29afee87194561654c6d360c | hangingman/go-monkey | /rcf/lexer/lexer_test.go | Go | go | 1,261 | no_license | package lexer
import (
"github.com/hangingman/go-monkey/rcf/token"
"testing"
)
func TestStatements(t *testing.T) {
input := `def fact(x) = if x>=2 then fact(x-1)*x else 1 fi
in fact(3)
`
tests := []struct {
expectedType token.TokenType
expectedLiteral string
}{
{token.DEF, "def"},
{token.IDENT, "fact... |
7f03a26f5ca1372503448a4ee65cab90b0a6facd | 74e3e83b11531471d8a88bd10bb1c6ef17964920 | ragrawal24/git-comment | /git-comment-grep/printer.go | Go | go | 613 | permissive | package main
import (
gx "exec"
"github.com/kylef/result.go/src/result"
gc "libgitcomment"
)
type Printer struct {
formatter *Formatter
pager *gx.Pager
}
func NewPrinter(useColor bool, pager *gx.Pager) *Printer {
return &Printer{&Formatter{useColor}, pager}
}
func (p *Printer) PrintCommentsMatching(wd, te... |
15a7cdf3a41f86989ec686aec0117c4e57e7f428 | e18d1622429d475c4a830e273adef49b4781235d | EmperorLeo/adventofcode2019 | /go/day4/day4.go | Go | go | 1,102 | no_license | package day4
import (
"fmt"
"strconv"
"strings"
"github.com/EmperorLeo/adventofcode2019/util"
)
/*Silver - Part 1 */
func Silver() {
passRange := strings.Split(util.ReadLines(4)[0], "-")
min, _ := strconv.Atoi(passRange[0])
max, _ := strconv.Atoi(passRange[1])
var count int
for i := min; i < max+1; i++ {
... |
d6faacc156aece5d686c3f3d43b2cd9b8db471cc | 63330f6e66231c738c29966eeeed140a4e083469 | 1linen1/milvus | /internal/datanode/segment_replica.go | Go | go | 17,595 | permissive | // Licensed to the LF AI & Data foundation under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use th... |
d86316faa3f9b1181643be6ead847939199075cd | 9d58e947a14073e4bcfeb5914370026e016f900c | vrtcal-dev/prebid-server | /exchange/bidder_test.go | Go | go | 105,548 | permissive | package exchange
import (
"bytes"
"context"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"net/http/httptest"
"net/http/httptrace"
"sort"
"strings"
"testing"
"time"
"github.com/golang/glog"
"github.com/prebid/openrtb/v19/adcom1"
nativeRequests "github.com/prebid/openrtb/v19/native1/requ... |
80123e1b0d6796dac8549debbd00459c0c6751c3 | 4df7cfbaddb3af640e41118fc8687413bee59499 | bastelfreak/go-choria | /aagent/watchers/timerwatcher/timer_test.go | Go | go | 2,663 | permissive | package timerwatcher
import (
"encoding/json"
"testing"
"time"
"github.com/choria-io/go-choria/aagent/model"
"github.com/golang/mock/gomock"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func Test(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "AAgent/Watchers/TimerWatcher")
}
var _ = Desc... |
aec998d8fc9350512017c6e48256889b3243a505 | a7ec08e23a17b322fcc83aa116f472d7eddc047f | Golan9/restapi-gorillamux | /modules/users/repositories/commands/command.go | Go | go | 469 | no_license | package commands
import (
"log"
m "restapi-gorillamux/modules/users/models"
database "restapi-gorillamux/database"
)
const (
// COLLECTION ..
COLLECTION = "users"
)
// Commands struct ..
type Commands struct{}
// Insert ..
func (c *Commands) Insert(user m.User) error {
//fmt.Println("masuk insert", user)
e... |
3fd21222619fb854d65e67a322b0df0a91464764 | 3cb4767205e62b5c6f89f8f9523d2ce7462ec891 | kayoub5/reviewdog | /doghouse/server/doghouse.go | Go | go | 7,904 | permissive | package server
import (
"bytes"
"context"
"fmt"
"net/http"
"strings"
"time"
"github.com/google/go-github/v29/github"
"github.com/reviewdog/reviewdog"
"github.com/reviewdog/reviewdog/diff"
"github.com/reviewdog/reviewdog/doghouse"
"github.com/reviewdog/reviewdog/service/github/githubutils"
)
// GitHub che... |
7de9b61b287ad101ed857311234b47852f779d19 | 60d6ac9799aae0859925f4a2869b05ad11bff3e3 | feisuzhu/rook | /tests/longhaul/base_block_test.go | Go | go | 7,365 | permissive | package longhaul
import (
"strings"
"sync"
"testing"
"time"
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
"github.com/rook/rook/tests/framework/clients"
"github.com/rook/rook/tests/framework/installer"
"github.com/rook/rook/tests/framework/utils"
"github.com/stretchr/testify/require"
)
var (
defau... |
9c0492198a36052c64584bd304eaad7c24566270 | b58b87114a418d3abc9c7b36e2659cc558c9e965 | NateWerner/httpbeat | /vendor/github.com/elastic/beats/libbeat/common/streambuf/io.go | Go | go | 4,331 | permissive | package streambuf
import (
"io"
"unicode/utf8"
)
func (b *Buffer) ioErr() error {
err := b.Err()
if err == ErrUnexpectedEOB || err == ErrNoMoreBytes {
return io.EOF
}
return err
}
func (b *Buffer) ioBufferEndError() error {
err := b.bufferEndError()
if err == ErrUnexpectedEOB || err == ErrNoMoreBytes {
r... |
572d90c9d7e56ec743b844f2dd1f46015801ee57 | 3d89fac775ccfab25430b8c9191a78e586c59696 | zhenzhaoya/multi-proxy | /config/config.go | Go | go | 2,091 | no_license | package config
import (
"encoding/json"
"io/ioutil"
"log"
"strings"
"github.com/zhenzhaoya/multiproxy/utils"
)
type ProxyEx struct {
All []string
Http []string
Https []string
}
type DomainSub struct {
Url string // 遇到时进行cookie,useragent,ip等缓存。同时清除cookie,修改useragent、ip
Domain string
Cookie ... |
ef8e66a9a42843f3d87e1ef3c1601c14c4f26a88 | ff62d5cc4ba9b74888fbcf10cefc7d5f32a0240a | MirrorTown/wayne | /src/backend/routers/commentsRouter_controllers_kubernetes_node.go | Go | go | 5,946 | permissive | package routers
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/context/param"
)
func init() {
beego.GlobalControllerRouter["github.com/Qihoo360/wayne/src/backend/controllers/kubernetes/node:KubeNodeController"] = append(beego.GlobalControllerRouter["github.com/Qihoo360/wayne/src/backend/controllers... |
cd062abb01f4228a12211c8575fa78575399dbba | 2639e9dd69270296972c55afb57fb42d3a1ecb04 | r-tamura/system-programming-in-go | /ch10/stat/stat.go | Go | go | 717 | no_license | package main
import (
"fmt"
"os"
"strings"
)
func main() {
if len(os.Args) == 1 {
fmt.Printf("%s [exec file name]", os.Args[0])
os.Exit(1)
}
targetFile := os.Args[1]
if strings.Index(targetFile, "-") != -1 {
targetFile = os.Args[2]
}
info, err := os.Stat(targetFile)
if err == os.ErrNotExist {
fmt.P... |
3fc65f252c7277576931f2f10b4ac046e123cc24 | 16d32648004bb300a5887b96fddec78f9702484c | KevinLeeCrosby/goUdemy | /structs/main.go | Go | go | 523 | no_license | package main
import "fmt"
type contactInfo struct {
email string
zipCode int
}
type person struct {
firstName string
lastName string
contactInfo
}
func main() {
jim := person{
firstName: "Jim",
lastName: "Party",
contactInfo: contactInfo{
email: "jim@gmail.com",
zipCode: 94000,
},
}
jim... |
81e59f91d62782dd3e612eaced95cc57524ae15d | 7133927d449e6f3c66b417acaa25bb8ba4b88ca8 | schnell18/gopl-exercise | /src/gopl.io/ch4/charcount.go | Go | go | 746 | no_license | package main
import (
"bufio"
"fmt"
"io"
"os"
"unicode"
"unicode/utf8"
)
func main() {
counts := make(map[rune]int)
var utflen [utf8.UTFMax + 1]int
invalid := 0
in := bufio.NewReader(os.Stdin)
for {
r, n, err := in.ReadRune()
if err == io.EOF {
break
}
if err != nil {
fmt.Fprintf(os.Stderr, ... |
7b0228fa99bf9fb15863536eb080db48a99a19cf | f7df4de75d3e746da1cc9e9fe93edc95b59bef9d | equinixmetal-archive/go-sensor | /example/httpclient/multi_request.go | Go | go | 1,233 | permissive | package main
import (
"fmt"
"net/http"
"time"
"github.com/instana/go-sensor"
ot "github.com/opentracing/opentracing-go"
)
func main() {
opts := instana.Options{LogLevel: instana.Debug}
recorder := instana.NewRecorder()
tracer := instana.NewTracerWithEverything(&opts, recorder)
fmt.Println("Hello. Sleeping... |
f1f67b5a0f6e5df1bc3d345d319ebab3b18334cd | 020c7d112fb83fc6948adce49afc0a2cc7c99805 | pro-collection/hd-mall-ed | /packages/client/router/shoppingCartRouter.go | Go | go | 949 | no_license | package router
import (
"github.com/gin-gonic/gin"
"hd-mall-ed/packages/client/controller/shoppingCartController"
)
func ShoppingCartRouter(router *gin.RouterGroup) {
shoppingCart := router.Group("/shopping_cart")
{
// 获取当前用户的所有购物车/临时订单
shoppingCart.GET("/get", shoppingCartController.GetList)
// 根据 id 获取信... |
d0dc10ecd3a22ae55d94948d5452b796eb300129 | 3bcd619c237bc36457f2213dcc844e413b0e19df | IamStubborN/otus-golang | /2019_07_11_homework_11/main.go | Go | go | 478 | no_license | package main
import (
"log"
"github.com/IamStubborN/otus-golang/2019_07_11_homework_11/genv"
"github.com/spf13/pflag"
)
var path *string
var appName *string
func init() {
path = pflag.StringP("path", "p", "", "genv -p ./envs")
appName = pflag.StringP("app", "a", "", "genv -a env")
pflag.Parse()
}
func main()... |
05fba6aab325b906f66bdcf847c48025ebe076fb | d325b62d179e7e3ae3e6bedf309416123c57c856 | Penthious/go-gql-meetup | /domain/utils/validators.go | Go | go | 1,561 | no_license | package utils
import (
"regexp"
)
var emailRegex = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
type Validator struct {
Errors map[string]string
}
type ElementMatcher struct {
field string
value string
... |
612fe20a42a89e6cec1e2f0159709917eba4e13f | 4e31533ee1e95868a441aca60c6e7208ac6dc1af | mu-box/golang-lvs | /lvs.go | Go | go | 2,353 | permissive | package lvs
import (
"errors"
"io"
"os/exec"
)
var (
Conflict = errors.New("object already exists")
NotFound = errors.New("object was not found")
DeleteFailed = errors.New("object was not deleted")
IpvsadmMissing = errors.New("unable to find the ipvsadm command on the system")
// these are to a... |
2820ba1296021a5029a5246c35dc2acf3abf7c10 | bf4de005e1264b882e7a5d0ebab817b52ccbac5c | skmetaly/golang-introduction | /17_helloworld_internet_style.go | Go | go | 331 | permissive | package main
import (
"fmt"
"log"
"net/http"
)
func HelloServer(w http.ResponseWriter, req *http.Request) {
log.Println(req.URL)
fmt.Fprintf(w, "Hello !\nURL = %s\n", req.URL)
}
func main() {
fmt.Println("Go to localhost:7777/hello")
http.HandleFunc("/hello", HelloServer)
log.Fatal(http.ListenAndServe(":7777... |
f9f98eddcb79bdc57f0fd066d768d7dbd7a969e4 | 6d88e757526937dbadb58a366107a5ab2a0c53a8 | huanshenyi/golang-IM | /controller/chat.go | Go | go | 2,245 | no_license | package controller
import (
"fmt"
"github.com/gorilla/websocket"
"gopkg.in/fatih/set.v0"
"log"
"net/http"
"strconv"
"sync"
)
//本核心在于形成userid和Node的映射关系
type Node struct {
Conn *websocket.Conn
//并行转串行,
DataQueue chan []byte
GroupSets set.Interface
}
//映射关系表
var clientMap map[int64]*Node = make(map[int64]*No... |
9315faa3452641e92b66fa7a83d91acba95956d7 | 223b9bd201b6b716ffa8be1ca53551c72c6de730 | atbeta/go_leetcode | /problems/121-BestTimeToBuyAndSellStock.go | Go | go | 1,376 | no_license | package problems
/**
121. Best Time to Buy and Sell Stock
Easy
Say you have an array for which the ith element is the price of a given stock on day i.
If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit.
Note th... |
b47a23ba31e3761729b42ce4118f67d1fb034d89 | eec606344d05642aa8278183f822ea1711123844 | shaohk/rancher | /pkg/catalog/manager/project_catalog_sync.go | Go | go | 1,498 | permissive | package manager
import (
"github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
)
func (m *Manager) ProjectCatalogSync(key string, obj *v3.ProjectCatalog) (*v3.ProjectCatalog, error) {
ns, name, err := cach... |
824c16b23eac2ccfbe7700ef66fc062796c89abc | 3120184ef7caa318b344d7452cdf5695a9926f18 | rhzx3519/leetcode | /go/src/leetcode/20. Valid Parentheses/20. Valid Parentheses.go | Go | go | 351 | no_license | package main
var mp = map[uint8]uint8 {
')' : '(',
'}' : '{',
']' : '[',
}
func isValid(s string) bool {
st := []uint8{}
for i, _ := range s {
if s[i]=='(' || s[i]=='{' || s[i]=='[' {
st = append(st, s[i])
} else {
if len(st)==0 || st[len(st)-1] != mp[s[i]] {
return false
}
st = st[:len(st)-1... |
2f7f390228c7b67339138d3b444a0e9d510db96e | 3c80b968f9a559392e2a0ea59a4738ebb0411470 | kprogk/goex | /29_nonBlockingChannelOperations/main.go | Go | go | 1,837 | no_license | /*////////////////////////////////////////////////////////////////////////////////
// //
// Author : Karthick K //
// Project : GO Example ... |
c253956aaa713562ba76d51d740e054fee4ad198 | a8f8cd491f267e0c85e7b51099e4000065efcb8f | phpyandong/opentaobao | /model/wdk/AlibabaIfpFulfillWarehouseTokenQueryResponse.go | Go | go | 757 | permissive | package wdk
import (
"encoding/xml"
"github.com/bububa/opentaobao/model"
)
/*
同城令牌打印接口 APIResponse
alibaba.ifp.fulfill.warehouse.token.query
用于仓内作业打印包裹信息
*/
type AlibabaIfpFulfillWarehouseTokenQueryAPIResponse struct {
model.CommonResponse
AlibabaIfpFulfillWarehouseTokenQueryResponse
}
type Alibab... |
d7939c981993742a0c9d4e92133b7abd4b2c9279 | 58f25c4b4ce6696d35e74bda0e03683ff7be832d | alex-ring/go-mapbox | /lib/directions_matrix/directions_matrix_test.go | Go | go | 1,115 | permissive | /**
* go-mapbox Directions Module Tests
* Wraps the mapbox directions API for server side use
* See https://www.mapbox.com/api-documentation/#retrieve-a-matrix for API information
*
* https://github.com/alex-ring/go-mapbox
* Copyright 2017 Ryan Kurte
*/
package directionsmatrix
import (
"os"
"testing"
)
imp... |
201f54512be2baea2e2c9da5297fc7b5f346c0a3 | dc400c7b781aa694add42e3b0c8bbb5ae797c58c | cantbewong/antrea | /pkg/antctl/transform/networkpolicy/transform.go | Go | go | 1,995 | permissive | // Copyright 2020 Antrea 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 ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.