Skip to content
/ flatten Public

A Go library which will flatten arrays of arbitrarily nested types.

License

Notifications You must be signed in to change notification settings

zikes/flatten

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flatten

Flattens an arbitrarily nested array of Type into a flat array of Type, e.g. [[1,2,[3]],4] -> [1,2,3,4].

Currently only the int type is supported via the flatten.Int function. Additional types may be supported in the future.

Example Usage

func Int([]interface{}) ([]int, error)

input := []interface{}{
  []interface{}{
    1,
    2,
    []interface{}{
      3,
    },
  },
  4,
}

ints := flatten.Int(input)
fmt.Println(ints) // [1 2 3 4]

About

A Go library which will flatten arrays of arbitrarily nested types.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages