A faster method to get elements from an interface (Struct or Slice type) for Go.

Overview

FastReflect

(English / 中文)

A faster method to get elements from an interface (Struct or Slice type) for Go.

Usage

import (
    "github.com/karminski/fastreflect"
)

// Access an interface (struct type) property by name
TheFieldYouWant := fastreflect.StructFieldByName(YourStructInterface, "FieldName")

// Get all elements from an interface (slice type)
AllElementsYouWant := fastreflect.SliceAllElements(YourSliceInterface)

For more details please see: FastReflect_test.go

Performance

  • Access an interface (struct type) property by name, 3.58x fast.
  • Get all elements from an interface (slice type), 4.3x fast.
root# go test -bench=.
goos: linux
goarch: amd64
BenchmarkStructFieldByName-8        14354080            78.6 ns/op
BenchmarkInternalFieldByName-8       4009170           297 ns/op
BenchmarkSliceAllElements-8         10825730           124 ns/op
BenchmarkInternalIndex-8             2514120           489 ns/op
PASS
ok      _/fastreflect/src   5.883s
Owner
karminski-牙医
karminski-牙医
A skip list of arbitrary elements that can be filtered using roaring bitmaps stored in an LRU cache

Skipfilter This package provides a data structure that combines a skiplist with a roaring bitmap cache. This library was created to efficiently filter

Kevin Burns 22 Aug 4, 2022
A slice backed binary heap with support for generic type parameters.

go-binaryheap A slice backed binary heap where the order can be customized by a comparison function. The main branch now requires go 1.18 because the

null 3 Jun 13, 2022
A slice-based implementation of a stack. In Go!

Stackgo Stackgo is a slice-based implementation of a simple stack in Go. It uses a pre-alloc pagination strategy which adds little memory overhead to

Alessandro Diaferia 15 Dec 13, 2021
Brushing questions is not the goal, but the mastering method is

Brushing questions is not the goal, but the mastering method is If you think it

null 2 Jan 8, 2022
Recursively searches a map[string]interface{} structure for another map[string]interface{} structure

msirecurse Recursively searches a map[string]interface{} structure for existence of a map[string]interface{} structure Motivation I wrote this package

Fred Moyer 1 Mar 3, 2022
skipmap is a high-performance concurrent sorted map based on skip list. Up to 3x ~ 10x faster than sync.Map in the typical pattern.

Introduction skipmap is a high-performance concurrent map based on skip list. In typical pattern(one million operations, 90%LOAD 9%STORE 1%DELETE), th

ZhangYunHao 73 Jul 31, 2022
My clean Go solution that's faster than 100%, takes up less memory than 100%.

Remove-element My very clean Go solution that's faster than 100% of all solutions on Leetcode. Leetcode Challenge: "Given an integer array nums and an

Daniel Pickens 0 Dec 24, 2021
TBH, there are probably better/faster implementations out there.

Scott's Skiplist TBH, there are probably better/faster implementations out there. See https://github.com/MauriceGit/skiplist-survey I wrote this one b

Scott White 1 Feb 10, 2022
Convert arbitrary formats to Go Struct (including json, toml, yaml, etc.)

go2struct Convert arbitrary formats to Go Struct (including json, toml, yaml, etc.) Installation Run the following command under your project: go get

Afeyer 34 Jul 6, 2022
An interesting go struct tag expression syntax for field validation, etc.

An interesting go struct tag expression syntax for field validation, etc.

Bytedance Inc. 1.2k Aug 8, 2022
Convert json string to Golang struct

json-to-go-cli Convert json string to Golang struct How to install git clone https://github.com/tiancheng92/json-to-go-cli.git cd json-to-go-cli go bu

TianCheng 7 May 10, 2022
GoStruct2Table - format your struct like a table.

GoStruct2Table format your struct like a table. Installing $ go get -u -v github.com/runningzyp/GoStruct2Table Simple Example import parser "github.c

YunpengZhan 9 Jun 14, 2022
A simple set type for the Go language. Trusted by Docker, 1Password, Ethereum and Hashicorp.

golang-set The missing set collection for the Go language. Until Go has sets built-in...use this. Coming from Python one of the things I miss is the s

Ralph Caraveo III 2.6k Aug 15, 2022
ID type with marshalling to/from hash to prevent sending IDs to clients.

Hide IDs Hide is a simple package to provide an ID type that is marshalled to/from a hash string. This prevents sending technical IDs to clients and c

Emvi 49 Aug 11, 2022
Null Types, Safe primitive type conversion and fetching value from complex structures.

Typ Typ is a library providing a powerful interface to impressive user experience with conversion and fetching data from built-in types in Golang Feat

Gurukami 32 Aug 5, 2022
Type-agnostic partitioning for Go's indexable collections and strings.

Go Type-Agnostic Collection Partitioning Type-agnostic partitioning for anything that can be indexed in Go - slices, arrays,strings. Inspired by Guava

Meir Fischer 35 Aug 11, 2021
flexible data type for Go

Generic flexible data type for Go support: Go 1.12+ Install standard go get: go get -u github.com/usk81/generic/v2 Usage encode/decode: package main

Yusuke Komatsu 43 May 19, 2022
Package set is a small wrapper around the official reflect package that facilitates loose type conversion and assignment into native Go types.

Package set is a small wrapper around the official reflect package that facilitates loose type conversion and assignment into native Go types. Read th

null 37 Jun 15, 2022
Type-safe, zero-allocation sets for Go

Set Package set is a type-safe, zero-allocation port of the excellent package fatih/set. It contains sets for most of the basic types and you can gene

ScyllaDB 795 Aug 10, 2022