tools

package module
v0.0.0-...-602008d Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: Apache-2.0 Imports: 1 Imported by: 2

README

Strings-go


Tools-go is a tool library for Golang.

License

Apache License, Version 2.0

Implements

TernaryOperator
  • TernaryOperator
  • TernaryOperatorNest
ReflectSupport
  • UnpackType
  • UnpackValue

Usage

Installation
go get -u github.com/guangzhou-meta/go-lib/tools
Demo
TernaryOperator
package main

import (
	"fmt"
	"time"
)

import (
	"github.com/guangzhou-meta/go-lib/tools"
)

func main() {
	condition := (time.Now().UnixNano()/1e6)%2 == 1
	trueResult := "true"
	falseResult := "false"
	result := tools.TernaryOperator(condition, trueResult, falseResult)
	fmt.Println(result)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TernaryOperator

func TernaryOperator(condition bool, trueResult interface{}, falseResult interface{}) interface{}

func TernaryOperatorFloat32

func TernaryOperatorFloat32(condition bool, trueResult float32, falseResult float32) float32

func TernaryOperatorFloat64

func TernaryOperatorFloat64(condition bool, trueResult float64, falseResult float64) float64

func TernaryOperatorInt

func TernaryOperatorInt(condition bool, trueResult int, falseResult int) int

func TernaryOperatorInt16

func TernaryOperatorInt16(condition bool, trueResult int16, falseResult int16) int16

func TernaryOperatorInt32

func TernaryOperatorInt32(condition bool, trueResult int32, falseResult int32) int32

func TernaryOperatorInt64

func TernaryOperatorInt64(condition bool, trueResult int64, falseResult int64) int64

func TernaryOperatorInt8

func TernaryOperatorInt8(condition bool, trueResult int8, falseResult int8) int8

func TernaryOperatorString

func TernaryOperatorString(condition bool, trueResult string, falseResult string) string

func TernaryOperatorUInt

func TernaryOperatorUInt(condition bool, trueResult uint, falseResult uint) uint

func TernaryOperatorUInt16

func TernaryOperatorUInt16(condition bool, trueResult uint16, falseResult uint16) uint16

func TernaryOperatorUInt32

func TernaryOperatorUInt32(condition bool, trueResult uint32, falseResult uint32) uint32

func TernaryOperatorUInt64

func TernaryOperatorUInt64(condition bool, trueResult uint64, falseResult uint64) uint64

func TernaryOperatorUInt8

func TernaryOperatorUInt8(condition bool, trueResult uint8, falseResult uint8) uint8

func UnpackType

func UnpackType(v reflect.Type) reflect.Type

func UnpackValue

func UnpackValue(v reflect.Value) reflect.Value

Types

type TernaryOperatorNestConditionFunc

type TernaryOperatorNestConditionFunc func() bool

type TernaryOperatorNestWrap

type TernaryOperatorNestWrap struct {
	// contains filtered or unexported fields
}

func TernaryOperatorNest

func TernaryOperatorNest(condition TernaryOperatorNestConditionFunc, trueResult interface{}, falseResult interface{}) *TernaryOperatorNestWrap

func (*TernaryOperatorNestWrap) Result

func (t *TernaryOperatorNestWrap) Result() interface{}

Jump to

Keyboard shortcuts

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