golang pass a struct returned function as argument
up vote
-1
down vote
favorite
I have a function that get a struct
as argument
func influxdb(r body) {
...
}
That struct before was globally available and is now imported from an external package
influxdb(jm.JsonBody(runPing(ip), yaml.YamlReader().Region))
The thing is that I don’t know now how to pass that as argument to my func influxdb()
I have passed in this way
func influxdb(r jm.JsonBody) {
but it complains
./main.go:35:15: jsonBodyMAC.JsonBody is not a type func influxdb(r whateverDatType)
here some details of the package imported
func JsonBody(splittedValues string, region string) Body {
…
return Body {
target
…
type Body struct {
target string
region string
...
go
add a comment |
up vote
-1
down vote
favorite
I have a function that get a struct
as argument
func influxdb(r body) {
...
}
That struct before was globally available and is now imported from an external package
influxdb(jm.JsonBody(runPing(ip), yaml.YamlReader().Region))
The thing is that I don’t know now how to pass that as argument to my func influxdb()
I have passed in this way
func influxdb(r jm.JsonBody) {
but it complains
./main.go:35:15: jsonBodyMAC.JsonBody is not a type func influxdb(r whateverDatType)
here some details of the package imported
func JsonBody(splittedValues string, region string) Body {
…
return Body {
target
…
type Body struct {
target string
region string
...
go
2
You pass the same type as the one returned by the imported function. If jm.JsonBody returns jm.Body, then it'sinfluxdb(b jm.Body)
.
– mkopriva
Nov 9 at 13:09
Yeap! That was the answer :)
– Allan Karllson
Nov 9 at 14:53
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I have a function that get a struct
as argument
func influxdb(r body) {
...
}
That struct before was globally available and is now imported from an external package
influxdb(jm.JsonBody(runPing(ip), yaml.YamlReader().Region))
The thing is that I don’t know now how to pass that as argument to my func influxdb()
I have passed in this way
func influxdb(r jm.JsonBody) {
but it complains
./main.go:35:15: jsonBodyMAC.JsonBody is not a type func influxdb(r whateverDatType)
here some details of the package imported
func JsonBody(splittedValues string, region string) Body {
…
return Body {
target
…
type Body struct {
target string
region string
...
go
I have a function that get a struct
as argument
func influxdb(r body) {
...
}
That struct before was globally available and is now imported from an external package
influxdb(jm.JsonBody(runPing(ip), yaml.YamlReader().Region))
The thing is that I don’t know now how to pass that as argument to my func influxdb()
I have passed in this way
func influxdb(r jm.JsonBody) {
but it complains
./main.go:35:15: jsonBodyMAC.JsonBody is not a type func influxdb(r whateverDatType)
here some details of the package imported
func JsonBody(splittedValues string, region string) Body {
…
return Body {
target
…
type Body struct {
target string
region string
...
go
go
edited Nov 9 at 13:12
mkopriva
7,32811317
7,32811317
asked Nov 9 at 13:05
Allan Karllson
1
1
2
You pass the same type as the one returned by the imported function. If jm.JsonBody returns jm.Body, then it'sinfluxdb(b jm.Body)
.
– mkopriva
Nov 9 at 13:09
Yeap! That was the answer :)
– Allan Karllson
Nov 9 at 14:53
add a comment |
2
You pass the same type as the one returned by the imported function. If jm.JsonBody returns jm.Body, then it'sinfluxdb(b jm.Body)
.
– mkopriva
Nov 9 at 13:09
Yeap! That was the answer :)
– Allan Karllson
Nov 9 at 14:53
2
2
You pass the same type as the one returned by the imported function. If jm.JsonBody returns jm.Body, then it's
influxdb(b jm.Body)
.– mkopriva
Nov 9 at 13:09
You pass the same type as the one returned by the imported function. If jm.JsonBody returns jm.Body, then it's
influxdb(b jm.Body)
.– mkopriva
Nov 9 at 13:09
Yeap! That was the answer :)
– Allan Karllson
Nov 9 at 14:53
Yeap! That was the answer :)
– Allan Karllson
Nov 9 at 14:53
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53226281%2fgolang-pass-a-struct-returned-function-as-argument%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
You pass the same type as the one returned by the imported function. If jm.JsonBody returns jm.Body, then it's
influxdb(b jm.Body)
.– mkopriva
Nov 9 at 13:09
Yeap! That was the answer :)
– Allan Karllson
Nov 9 at 14:53