Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: document where service names come from? #31249

Closed
safety-tom opened this issue Apr 4, 2019 · 5 comments
Closed

net: document where service names come from? #31249

safety-tom opened this issue Apr 4, 2019 · 5 comments
Labels
Documentation FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. Suggested Issues that may be good for new contributors looking for work to do.
Milestone

Comments

@safety-tom
Copy link

Found in net/http/server.go:

type Server struct {
	Addr    string  // TCP address to listen on, ":http" if empty

What is this ":http" exactly? Presumably an alias, but I can't find any concrete documentation to know what it resolves to.

Addr string // TCP address to listen on, ":http" if empty

@bradfitz
Copy link
Contributor

bradfitz commented Apr 4, 2019

https://golang.org/pkg/net/#Listen references
https://golang.org/pkg/net/#Dial which says "The port must be a literal port number or a service name."

Perhaps we should mention that comes from /etc/services (or equivalent, depending on OS).

@bradfitz bradfitz changed the title What is ":http"? net: document where service names come from? Apr 4, 2019
@bradfitz bradfitz added this to the Go1.13 milestone Apr 4, 2019
@agnivade agnivade added the Suggested Issues that may be good for new contributors looking for work to do. label Apr 4, 2019
@cuonglm
Copy link
Member

cuonglm commented Apr 4, 2019

@bradfitz How about mention that service name is defined in RFC 6335, and assigned by IANA

For each OS:

  • *nix: /etc/services
  • Windows: %WINDIR%\system32\drivers\etc\services
  • Plan 9: /lib/ndb/{local,global}

Document each OS seems too much details.

@andybons andybons added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 4, 2019
@luka-zitnik
Copy link
Contributor

Is there missing a description of the address format in general? -- Empty host or port, port "0", square brackets for ipv6 addresses, ... As a reader of the comment I would also be interested in what does using the service name effectively means -- will it be port 80 or a dynamically assigned port from the 80** range?

Can we do something like this?

type Server struct {

	// TCP address to listen on, ":http" (all IP addresses,
	// default http port) if empty
	// See package net for description of the address format
	Addr string

@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@AndersonQ
Copy link
Contributor

As this issue has been inactive for a while, I'll submit a PR following @luka-zitnik suggestion.

@gopherbot
Copy link

Change https://golang.org/cl/191557 mentions this issue: net/http: enhance documentation for Server.Addr

tomocy pushed a commit to tomocy/go that referenced this issue Sep 1, 2019
Fixes golang#31249

Change-Id: I3280f8ab170ed31d4efb71106533e016d430d44c
Reviewed-on: https://go-review.googlesource.com/c/go/+/191557
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
t4n6a1ka pushed a commit to t4n6a1ka/go that referenced this issue Sep 5, 2019
Fixes golang#31249

Change-Id: I3280f8ab170ed31d4efb71106533e016d430d44c
Reviewed-on: https://go-review.googlesource.com/c/go/+/191557
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@golang golang locked and limited conversation to collaborators Aug 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. Suggested Issues that may be good for new contributors looking for work to do.
Projects
None yet
Development

No branches or pull requests

8 participants