cast

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 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 AsBoolArray

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

AsBoolArray to convert as an array of bool

func AsDatetime

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

AsDatetime to convert as datetime (time.Time)

func AsDatetimeArray

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

AsDatetimeArray to convert as an array of datetime

func AsDuration added in v1.0.1

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

AsDuration to convert as a duration

func AsDurationArray added in v1.0.1

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

AsDurationArray to convert as an array of duration

func AsFloat

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

AsFloat to convert as a float64

func AsFloatArray

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

AsFloatArray to convert as an array of float64

func AsInt

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

AsInt to convert as a int64 <!> for now, no overflow detection

func AsIntArray

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

AsIntArray to convert as an array of int64

func AsString

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

AsString to convert as string

func AsStringArray

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

AsStringArray to convert as an array of string

func AsUint added in v1.1.0

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

AsUint to convert as a uint64 <!> for now, no overflow detection

func AsUintArray added in v1.1.0

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

AsUintArray to convert as an array of uint64

Types

This section is empty.

Jump to

Keyboard shortcuts

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