-2
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.

Rawley Fowler
  • 1,366
  • 7
  • 15

1 Answers1

0

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{}
Rawley Fowler
  • 1,366
  • 7
  • 15
  • Thanks. This worked for the most part but showed some about four new errors elsewhere. I'ma scrap everything and start from scratch again but keeping the var client http.Client – grandmasternik Jul 27 '22 at 22:30