Closed adrianlop closed 5 years ago
@adrianlop Found the root issue why it was unable discover the method from controller struct.
I have reviewed you code and also aah AST flow. When Package files gets processed by aah AST code. There are no guaranteed order in the file processing for type & method
since its type map[string]*File
.
So as per your code, controller defined oncaller.go
and action methods are defined all three files. Following log lines from random execution on my machine would convey what I mean.
2019-02-06 22:08:01.329 ERROR AST: Method 'TriggerGrafanaCall' has incorrect struct recevier 'Controller' on file [/xxx/ops-api/app/controllers/oncaller/grafana_webhook.go] at line #12
2019-02-06 22:08:01.329 ERROR AST: Method 'TriggerPrometheusCall' has incorrect struct recevier 'Controller' on file [/xxx/ops-api/app/controllers/oncaller/prometheus_webhook.go] at line #15
2019-02-06 22:08:11.154 ERROR AST: Method 'TriggerPrometheusCall' has incorrect struct recevier 'Controller' on file [/xxx/ops-api/app/controllers/oncaller/prometheus_webhook.go] at line #15
So solution to address this issue is to process all types for the package first and then go for processing methods.
I have made a release of aah v0.12.3
&& cli v0.13.4
.
just updated the framework and the cli. it's working :) great stuff @jeevatkm, thank you very much for fixing this!
What version of aah are you using (
aah --version
)?aah v0.12.2 cli v0.13.3 go v1.11.5
Does this issue reproduce with the latest release?
yes
What operating system are you using (such as macOS, Linux and Windows)?
MacOS X
What did you do?
aah build
What did you expect to see?
successful build + being able to implement several methods for the same controller struct on several files.
What did you see instead?
Additional context
If I create an additional struct like I showed you @jeevatkm then the build doesn't throw any error.