Comments (5)
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.
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.
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.
Thanks, would this still be considered a bug?
A part of me feels like there should never be //go:generate
's lingering?
from genny.
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)
- Imports not generated correctly HOT 3
- Separate generated code in multiple files HOT 3
- Flags usage not correct in README HOT 1
- Suggestion: make the genny project visible to Hacktoberfest searches. Add a contributing.md file too.
- Is this project still maintained? HOT 2
- wordify breaks calls to APIs made while generating
- -pkg doesn't appear to work HOT 2
- code cleanup in parse.go drops all import statements and is potentially buggy in other infrequent scenarios HOT 1
- Lowercase replace in strings? HOT 6
- Collect generics into composed interface HOT 2
- Switch to a standard codegen comment marker
- Are slices supported? HOT 1
- Allow generation of exported and non exported types from the same generic code.
- TestCustomTypesMap test fails on some systems
- running "genny": exec: "genny": executable file not found in $PATH HOT 3
- Check if specific type name has a valid syntax
- Drops imports on github actions HOT 1
- import stmt removed in output (sometimes) HOT 2
- Please create a new tag for the latest master branch
- generic.Type support function definition ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from genny.