FAQ: Learn Go: Variables and Types - Inferring Type

This community-built FAQ covers the “Inferring Type” exercise from the lesson “Learn Go: Variables and Types”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Go

FAQs on the exercise Inferring Type

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in #get-help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to #get-help and #community:tips-and-resources. If you are wanting feedback or inspiration for a project, check out #project.

Looking for motivation to keep learning? Join our wider discussions in #community

Learn more about how to use this guide.

Found a bug? Report it online, or post in #community:Codecademy-Bug-Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I’m still not sure about the final part of inferring types…as the lesson states:


Why would you ever use := when = does the same thing about inferring the type?

You are right. The application of inferred types is not used in the example. Clearly a key feature is either missing or left out for us to understand.
var someThing := “That thing” is what is expected


Try as I might, I can’t for the life of me figure out what I’m doing wrong.

(Sorry for the double post, but I can’t embed more than one image in a post.)

The solution was no help, either…

Hi jigsy,

I had the same issue, and searched here. When I copy pasted the code into my IDE and cleaned it up, this worked (in codeacademy):

package main

import “fmt”

func main() {
// Define daysOnVacation using := below:
var daysOnVacation := 7
var hoursInDay = 24

// Define hoursInDay using var and = below:

fmt.Println("You have spent", daysOnVacation * hoursInDay, "hours on vacation.")


Hope that helps

When approaching prompt 2, change the operator on prompt 1 as well, then submit.

Apparently, you can’t mix := and =. You have to use one or the other in your code for inference, unlike codecademy request you do. Otherwise, you will get an error. Let me know if I am wrong.