Undefined: http.MethodGet

When I try go build in my project I get “rest/rest.go:18: undefined: http.MethodGet”. I get the same error when I run go fix or go get as well. This is only happening on my Raspberry Pi. When I run go build on my Windows 10 PC it builds fine.

package rest

import (

// Start starts the server
func Start() {
	http.HandleFunc("/numberconverter", numberconverter)
	http.ListenAndServe(":80", nil)

func numberconverter(writer http.ResponseWriter, response *http.Request) {
	// Check if the method is a get
	if response.Method != http.MethodGet {
		http.Error(writer, http.StatusText(405), 405)

	number := response.FormValue("number")
	oldBase := response.FormValue("oldBase")
	newBase := response.FormValue("newBase")
	result := converter.ConvertStringNumberToNewBase(number, oldBase, newBase)
	fmt.Fprintf(writer, "%s base %s is %s in base %s", number, oldBase, result, newBase)

You probably need a newer Go. Compare the output of go version and upgrade as appropriate.

1 Like

You are correct. I was running 1.3 on my Raspberry Pi. Thank you!

Why don’t you compile from your windows system using proper GOARCH and GOOS values?

I don’t want to have to keep switching between Windows and Linux compilation. I want to be able to compile on both.

Cross compiling from windows to pi might be much faster, also you do not need to install go on the pi then, which already has only very limited space available.

I’m not developing anything big right now, I’m just trying to learn the language. I’m dealing with less than 100 lines of code right now.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.