mirror of
https://github.com/teivah/100-go-mistakes.git
synced 2026-06-21 00:47:11 +08:00
Merge pull request #109 from Nattfarinn/patch-2
Update formatting for mistake #11
This commit is contained in:
commit
7f9c00ef61
1 changed files with 5 additions and 5 deletions
|
|
@ -229,10 +229,10 @@ type Option func(options *options) error
|
||||||
func WithPort(port int) Option {
|
func WithPort(port int) Option {
|
||||||
return func(options *options) error {
|
return func(options *options) error {
|
||||||
if port < 0 {
|
if port < 0 {
|
||||||
return errors.New("port should be positive")
|
return errors.New("port should be positive")
|
||||||
}
|
}
|
||||||
options.port = &port
|
options.port = &port
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -251,7 +251,7 @@ func NewServer(addr string, opts ...Option) ( *http.Server, error) {
|
||||||
if options.port == nil {
|
if options.port == nil {
|
||||||
port = defaultHTTPPort
|
port = defaultHTTPPort
|
||||||
} else {
|
} else {
|
||||||
if *options.port == 0 {
|
if *options.port == 0 {
|
||||||
port = randomPort()
|
port = randomPort()
|
||||||
} else {
|
} else {
|
||||||
port = *options.port
|
port = *options.port
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue