Code Monkey home page Code Monkey logo

gosli's Introduction

gosli

The goal of this library is to make easier to work with slices in Go. It was inspired by .NET LINQ query language.

Since Go doesn't have generic methods, sometimes it's hard to choose a nice-looking way to find some element in a slice or how to filter it. It's pretty easy to use for loop for it, but we can face with a compromise between the DRY (Don't Repeat Yourself) principle and using interface{} (the thing that I try to avoid if possible as a big fan of strong typing).

Also, there was an idea to avoid using the reflect package, because performance really matters for the most of golang applications, and reflect might be slow.

So, after all, maybe a good way to deal with is to implement some code generator. And here comes gosli.

Gosli now has two ways for using:

  • If you want to use gosli to work with slices of basic golang type, for example to find or filter something in a slice of strings, you can do it just out-of-the box. Read more
  • Or you can generate a wrapper for any of your custom type to work with slices of it. In a few words, the generator can create for your MyType structure two wrappers: MyTypeSlice and MyTypePSlice (where P is for 'pointer') Read more

gosli's People

Contributors

doctornick42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gosli's Issues

Support slices of values

The code generator creates methods for slices of pointers:

gosli experiment/faketype.go FakeType

type FakeTypeSlice []*FakeType

It would be better to generate all possible methods both for slices of structures and for pointers.

gosli experiment/faketype.go FakeType

type FakeTypeSlice []*FakeType

type FakeTypeValueSlice []FakeType

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.