Giter VIP home page Giter VIP logo

Comments (4)

matryer avatar matryer commented on August 20, 2024

I think the generated code is invalid - does the code compile before genny is run?

from genny.

pdrum avatar pdrum commented on August 20, 2024

The problem seems to be with the compile error. Therefore closing the issue.

from genny.

libmonsoon-dev avatar libmonsoon-dev commented on August 20, 2024

I have a similar problem.

from.go:


import "github.com/cheekybits/genny/generic"

type T generic.Type

func sliceFromChanT(ch <-chan T) []T {
	items := make([]T, len(ch))

	for item := range ch {
		items = append(items, item)
	}

	return items
}

cat from.go | genny gen "T=[]error":
Failed to goimports the generated code: stdout:11:18: expected '(', found '[' (and 1 more errors)

go env

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go-1.12"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.12/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build417713142=/tmp/go-build -gno-record-gcc-switches"

from genny.

libmonsoon-dev avatar libmonsoon-dev commented on August 20, 2024

It looks like a problem in the function name generation.
If you remove the generic from the function name (T), everything works as expected.

cat from.go | genny gen "T=[]error"

// This file was automatically generated by genny.
// Any changes will be lost if this file is regenerated.
// see https://github.com/cheekybits/genny

package slice

func sliceFromChan(ch <-chan []error) [][]error {
        items := make([][]error, len(ch))

        for item := range ch {
                items = append(items, item)
        }

        return items
}

from genny.

Related Issues (20)

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.