cast

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: Apache-2.0 Imports: 3 Imported by: 6

README

Cast

Circle CI Go Report Card GoDoc GitHub stars GitHub license

datasweet-logo

Cast is a Go package to simply cast an interface to a specific type in go, without panic !

Installation

go get github.com/datasweet/cast

Usage

Casting to a time.Time
import (
  "fmt"
  "github.com/datasweet/cast"
)

func main() {
  j := cast.AsDatetime("13/03/2019")
  fmt.Println(j)
}

Who are we ?

We are Datasweet, a french startup providing full service (big) data solutions.

Questions ? problems ? suggestions ?

If you find a bug or want to request a feature, please create a GitHub Issue.

License

This software is licensed under the Apache License, version 2 ("ALv2"), quoted below.

Copyright 2019 Datasweet <http://www.datasweet.fr>

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
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsBool

func AsBool(v interface{}) (bool, bool)

AsBool to convert as bool

func AsBoolSlice added in v1.2.0

func AsBoolSlice(values ...interface{}) ([]bool, bool)

AsBoolSlice to convert as a slice of bool

func AsDuration added in v1.0.1

func AsDuration(v interface{}) (time.Duration, bool)

AsDuration to convert as a duration

func AsDurationSlice added in v1.2.0

func AsDurationSlice(values ...interface{}) ([]time.Duration, bool)

AsDurationSlice to convert as a slice of duration

func AsFloat32 added in v1.2.0

func AsFloat32(v interface{}) (float32, bool)

AsFloat32 to convert as a float32

func AsFloat32Slice added in v1.2.0

func AsFloat32Slice(values ...interface{}) ([]float32, bool)

AsFloat32Slice to convert as a slice of float32

func AsFloat64 added in v1.2.0

func AsFloat64(v interface{}) (float64, bool)

AsFloat64 to convert as a float64

func AsFloat64Slice added in v1.2.0

func AsFloat64Slice(values ...interface{}) ([]float64, bool)

AsFloat64Slice to convert as a slice of float64

func AsInt

func AsInt(v interface{}) (int, bool)

AsInt to convert as a int

func AsInt8 added in v1.2.0

func AsInt8(v interface{}) (int8, bool)

AsInt8 to convert as a int8

func AsInt8Slice added in v1.2.0

func AsInt8Slice(values ...interface{}) ([]int8, bool)

AsInt8Slice to convert as a slice of int8

func AsInt16 added in v1.2.0

func AsInt16(v interface{}) (int16, bool)

AsInt16 to convert as a int16

func AsInt16Slice added in v1.2.0

func AsInt16Slice(values ...interface{}) ([]int16, bool)

AsInt16Slice to convert as a slice of int16

func AsInt32 added in v1.2.0

func AsInt32(v interface{}) (int32, bool)

AsInt32 to convert as a int32

func AsInt32Slice added in v1.2.0

func AsInt32Slice(values ...interface{}) ([]int32, bool)

AsInt32Slice to convert as a slice of int32

func AsInt64 added in v1.2.0

func AsInt64(v interface{}) (int64, bool)

AsInt64 to convert as a int64

func AsInt64Slice added in v1.2.0

func AsInt64Slice(values ...interface{}) ([]int64, bool)

AsInt64Slice to convert as a slice of int64

func AsIntSlice added in v1.2.0

func AsIntSlice(values ...interface{}) ([]int, bool)

AsIntSlice to convert as a slice of int

func AsString

func AsString(v interface{}) (string, bool)

AsString to convert as string

func AsStringSlice added in v1.2.0

func AsStringSlice(values ...interface{}) ([]string, bool)

AsStringSlice to convert as a slice of string

func AsTime added in v1.2.0

func AsTime(v interface{}, format ...string) (time.Time, bool)

AsTime to convert as time.Time You can pass golang format for a string conversion

func AsTimeSlice added in v1.2.0

func AsTimeSlice(values ...interface{}) ([]time.Time, bool)

AsTimeSlice to convert as a slice of time

func AsUint added in v1.1.0

func AsUint(v interface{}) (uint, bool)

AsUint to convert as a uint

func AsUint8 added in v1.2.0

func AsUint8(v interface{}) (uint8, bool)

AsUint8 to convert as a int8

func AsUint8Slice added in v1.2.0

func AsUint8Slice(values ...interface{}) ([]uint8, bool)

AsUint8Slice to convert as a slice of uint8

func AsUint16 added in v1.2.0

func AsUint16(v interface{}) (uint16, bool)

AsUint16 to convert as a int16

func AsUint16Slice added in v1.2.0

func AsUint16Slice(values ...interface{}) ([]uint16, bool)

AsUint16Slice to convert as a slice of uint16

func AsUint32 added in v1.2.0

func AsUint32(v interface{}) (uint32, bool)

AsUint32 to convert as a uint32

func AsUint32Slice added in v1.2.0

func AsUint32Slice(values ...interface{}) ([]uint32, bool)

AsUint32Slice to convert as a slice of uint32

func AsUint64 added in v1.2.0

func AsUint64(v interface{}) (uint64, bool)

AsUint64 to convert as a int64

func AsUint64Slice added in v1.2.0

func AsUint64Slice(values ...interface{}) ([]uint64, bool)

AsUint64Slice to convert as a slice of uint64

func AsUintSlice added in v1.2.0

func AsUintSlice(values ...interface{}) ([]uint, bool)

AsUintSlice to convert as a slice of uint

Types

This section is empty.

Jump to

Keyboard shortcuts

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