Giter VIP home page Giter VIP logo

Comments (5)

xiegeo avatar xiegeo commented on August 20, 2024 1

I can reproduce now.

Change $GOPATH/bin/genny to genny will fix it. After putting $GOPATH/bin/ in your path, and delete any existing gen_* files.

It looks like genny only recognize //go:generate genny ... as a genny command to be removed from the output, and not when the full path is specified.

from genny.

xiegeo avatar xiegeo commented on August 20, 2024

I don't run in to this problem.
With:

package ...

import (
    "bytes"
    "encoding/binary"
    "github.com/cheekybits/genny/generic"
)

//go:generate genny -in=$GOFILE -out=gen_$GOFILE gen "ValueType=int16,int32,float32"

type ValueType generic.Type

func ...

go generate produces:

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

package ...

import (
    "bytes"
    "encoding/binary"
)

func ...

Can you show a simplified version of your file so others can reproduce it?

from genny.

ammario avatar ammario commented on August 20, 2024

This is what I'm using

package util
//go:generate $GOPATH/bin/genny -in=$GOFILE -out=gen-$GOFILE gen "valueType=Thread"


import (
        "sync"

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

type valueType generic.Type

//valueTypeSlice is a synchronizable slice that supports easy deletion of indices.
type valueTypeSlice struct {
        Slice []valueType
        sync.Mutex
}

//Delete deletes an index from a slice by replacing the value at the end with the last index then reslicing to prune the last element.
//A call to delete must be synchronized via the built in mutex.
//Delete does not check bounds and will panic if index is outside the bounds of the slice.
func (s *valueTypeSlice) Delete(index int) {
        s.Slice[index] = s.Slice[len(s.Slice)-1]
        if len(s.Slice) > 0 {
                s.Slice = s.Slice[:len(s.Slice)-1]
        }

}

go generate (1.6.2) produces

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

package util

import "sync"

//go:generate $GOPATH/bin/genny -in=$GOFILE -out=gen-$GOFILE gen "Thread=Thread"

//ThreadSlice is a synchronizable slice that supports easy deletion of indices.
type ThreadSlice struct {
        Slice []Thread
        sync.Mutex
}

//Delete deletes an index from a slice by replacing the deleted value with the last value of the slice and pruning.
//A call to delete must be synchronized via the built in mutex.
//Delete does not check bounds and will panic if index is outside the bounds of the slice.
func (s *ThreadSlice) Delete(index int) {
        s.Slice[index] = s.Slice[len(s.Slice)-1]
        if len(s.Slice) > 0 {
                s.Slice = s.Slice[:len(s.Slice)-1]
        }

}

from genny.

ammario avatar ammario commented on August 20, 2024

Thanks, would this still be considered a bug?

A part of me feels like there should never be //go:generate's lingering?

from genny.

loren-osborn avatar loren-osborn commented on August 20, 2024

Just as a related comment $GOPATH/bin/genny should probably not be used as GOPATH can contain multiple paths separated by colons, but it would be nice if genny could register itself as a β€œtool” known by the compiler.

I personally have never put the //go:generate in the generic file before as it seems the client calling the generic should usually be the one specifying how it’s expanded.

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.