Comments (6)
What about having T as int and use []T in your code when you need slices?
Sent from my iPhone
On 18 Sep 2015, at 16:07, falafflepotatoe [email protected] wrote:
Hey. I'm having good success with genny but now I have a spazzy-issues.
Code:
func pop(arr _T) BASETYPE { l := len(_arr)-1; val := (_arr)[l]; *arr = (_arr)[:l]; return val }
QuestionHow can I set basetype to "int" when T is []int? so the return type is the base type... ex: return "int" when my code generates []int., float when T is []float etc
I tried:
func pop(arr TSlice) T { l := len(arr)-1; val := (arr)[l]; *arr = (arr)[:l]; return val }but after running go generate Tslice is named "intSlice" so I cannot export it, which is my next question:
I'm exporting my package so custom types have to be Uppercased, so the way I was building slices is no longer work
—
Reply to this email directly or view it on GitHub.
from genny.
@matryer thats what I was doing initially, however for builtins... go does not allow you to use them as receivers in functions
ex: func (arr []int) pop () {...}
is invalid, so I have to use a custom type IntSlice.
from genny.
Question for you guys!
I want to release my generated .go file as a package
but I want to include the src/template so they can add types and regenerate it.
But the template should not be in the pkg (the code/varnames conflict as the T variables are not defined)
I guess you cannot change the extension of a file before using go generate. Any idea how to do this?
from genny.
You can use build tags to prevent template files from being build as part of the package?
// +build ignore
On 9 Oct 2015, at 10:54, falafflepotatoe [email protected] wrote:
Question for you guys!
I want to release my generated .go file as a package
but I want to include the src/template so they can add types and regenerate it.
But the template should not be in the pkg (the code/varnames conflict as the T variables are not defined)Any idea how to do this?
—
Reply to this email directly or view it on GitHub #13 (comment).
from genny.
yea! thanks a lot sir.
from genny.
One last question: Im using two vars and getting 2x2x2x2 results instead of 2x2 (4) generated functions
the vars are BASE_TYPE (=int,float) and SLICE (=IntSlice,FloatSlice)
I dont need a type IntSlice []float, and a Floatslice []int
anyway to not get double the results?
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.