Knaph

Constants

Constants

const is for values that are fixed at compile time and can never be reassigned:

const Pi = 3.14159
const MaxRetries = 3

Attempting MaxRetries = 4 later is a compile error, not a lint warning. Use const for the "this should never change" values in your program — timeouts, limits, magic numbers you want named — the same instinct as Python's SCREAMING_SNAKE_CASE module constants, except Go actually enforces it.

Sign in to track your progress through this course.

Ask an AI

Open a ready-made prompt in ChatGPT or Claude — just press Enter.

SummarizeChatGPTClaude
Ask me questionsChatGPTClaude
Let's learn togetherChatGPTClaude