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
TomitaSilvestruSC opened this issue Apr 4, 2019 · 5 comments
Closed

net: document where service names come from? #31249

TomitaSilvestruSC opened this issue Apr 4, 2019 · 5 comments

Comments

@TomitaSilvestruSC
Copy link

@TomitaSilvestruSC TomitaSilvestruSC commented Apr 4, 2019

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

This comment has been minimized.

Copy link
Contributor

@bradfitz 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 the help wanted label Apr 4, 2019
@bradfitz bradfitz added this to the Go1.13 milestone Apr 4, 2019
@agnivade agnivade added the Suggested label Apr 4, 2019
@cuonglm

This comment has been minimized.

Copy link
Contributor

@cuonglm 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 label Apr 4, 2019
@luka-zitnik

This comment has been minimized.

Copy link
Contributor

@luka-zitnik luka-zitnik commented Apr 5, 2019

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

This comment has been minimized.

Copy link
Contributor

@AndersonQ AndersonQ commented Aug 23, 2019

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

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Aug 23, 2019

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

@gopherbot gopherbot closed this in 2b59894 Aug 27, 2019
tomocy added 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 added 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.