Skip to content

x/website: error in documentation example #41168

@ckharide

Description

@ckharide

What version of Go are you using (go version)? 1.15

$ go version

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)? MAC OS

go env Output
$ go env

What did you do? Run a simple module program in your golang page.

What did you expect to see? The file hello.go has a wrong reference to the greeting variable.

Please look at this file in https://golang.org/doc/tutorial/call-module-code.

What did you see instead?

package main

import (
"fmt"
"example.com/greetings"
)

func main() {
// Get a greeting message and print it.
message := greetings.Hello("Gladys")
fmt.Println(greeting) /* This should be message */ => it yields compilation error "./hello.go:12:17: undefined: greeting"
}

Please change it to

func main() {
// Get a greeting message and print it.
message := greetings.Hello("Gladys")
fmt.Println(message)
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions