Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Missing Filed or Method

var client := http.Client

For whatever reason this code is giving the error message missing variable or initialization. Can someone enlighten me on why? I’m not understanding what I have done wrong

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

In Go we use := or var = for initializing variables. In your case you can re-write it to be:

var client = http.Client{}

or

client := http.Client{}

Either of these will trigger type inference of the variable. You can use var with a type to explicitly declare a type as well. In your case if you wanted to enforce the type you could write:

var client http.Client = http.Client{}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading