demo

package
v0.0.0-...-a2b96ca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2025 License: MIT Imports: 6 Imported by: 0

README

Code Examples

This is a collection of coding examples in Go (golang).


Golang Topics


Others

Documentation

Overview

Package demo :: chan.go

Package demo :: foo.go

Package demo :: integer.go

Package demo :: pipe.go

Index

Constants

View Source
const (
	// MaxUint represents maximum unsigned integer
	MaxUint uint = ^(uint(0))
	// MaxUint8 represents maximum 8-bit unsigned integer
	MaxUint8 uint8 = ^(uint8(0))
	// MaxUint16 represents maximum 16-bit unsigned integer
	MaxUint16 uint16 = ^(uint16(0))
	// MaxUint32 represents maximum 32-bit unsigned integer
	MaxUint32 uint32 = ^(uint32(0))
	// MaxUint64 represents maximum 64-bit unsigned integer
	MaxUint64 uint64 = ^(uint64(0))

	// MaxInt represents maximum integer
	MaxInt int = int(^uint(0) >> 1) // int(MaxUint >> 1)
	// MinInt represents minimum integer
	MinInt int = ^int(^uint(0) >> 1) // ^MaxInt

	// MaxInt8 represents maximum 8-bit integer
	MaxInt8 int8 = int8(^uint8(0) >> 1) // int(MaxUint8 >> 1)
	// MinInt8 represents minimum 8-bit integer
	MinInt8 int8 = ^int8(^uint8(0) >> 1) // ^MaxInt8

	// MaxInt16 represents maximum 16-bit integer
	MaxInt16 int16 = int16(^uint16(0) >> 1) // int(MaxUint16 >> 1)
	// MinInt16 represents minimum 16-bit integer
	MinInt16 int16 = ^int16(^uint16(0) >> 1) // ^MaxInt16

	// MaxInt32 represents maximum 32-bit integer
	MaxInt32 int32 = int32(^uint32(0) >> 1) // int(MaxUint32 >> 1)
	// MinInt32 represents minimum 32-bit integer
	MinInt32 int32 = ^int32(^uint32(0) >> 1) // ^MaxInt32

	// MaxInt64 represents maximum 64-bit integer
	MaxInt64 int64 = int64(^uint64(0) >> 1) // int64(MaxUint64 >> 1)
	// MinInt64 represents minimum 64-bit integer
	MinInt64 int64 = ^int64(^uint64(0) >> 1) // ^MaxInt64
)

Variables

This section is empty.

Functions

func Atoi

func Atoi(input string) int64

Atoi converts string to integer Note: 0 for valid decimal number; return max or min on overflow

func DecodeInteger

func DecodeInteger(code int, length int) (x, y int)

DecodeInteger decrypts code by length to two integers

func EncodeIntegers

func EncodeIntegers(x, y, length int) int

EncodeIntegers crypts two integers by length

func GetMergedChannels

func GetMergedChannels(ch1, ch2 <-chan int) <-chan int

GetMergedChannels merges two channels to one. See https://medium.com/justforfunc/why-are-there-nil-channels-in-go-9877cc0b2308 Notes: in common pattern, each channel (e.g. `ch` as `chan<- int`)

  • receives data in a lengthy producer (e.g. `ch <- v`)
  • closes at the end of the producer

func MergeChannels

func MergeChannels(out chan float32, inputs []chan float32)

MergeChannels merges inputs to one out channel

Types

type Foo

type Foo struct {
	Anything interface{}
}

Foo struct is a template of using interface data

func (*Foo) GetAnything

func (f *Foo) GetAnything() interface{}

GetAnything is a template function returning interface

func (*Foo) String

func (f *Foo) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL