Skip to content

Commit

Permalink
trifle: refine go build tags of operating systems
Browse files Browse the repository at this point in the history
  • Loading branch information
panjf2000 committed Jul 3, 2020
1 parent c3907e0 commit 637144b
Show file tree
Hide file tree
Showing 26 changed files with 31 additions and 72 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<br />
<a title="Build Status" target="_blank" href="https://travis-ci.com/panjf2000/gnet"><img src="https://img.shields.io/travis/com/panjf2000/gnet?style=flat-square&logo=travis-ci&logoColor=white"></a>
<a title="Codecov" target="_blank" href="https://codecov.io/gh/panjf2000/gnet"><img src="https://img.shields.io/codecov/c/github/panjf2000/gnet?style=flat-square&logo=codecov"></a>
<a title="Supported Platforms" target="_blank" href="https://github.com/panjf2000/gnet"><img src="https://img.shields.io/badge/platform-Linux%20%7C%20FreeBSD%20%7C%20Darwin%20%7C%20Windows-549688?style=flat-square&logo=dlna"></a>
<a title="Supported Platforms" target="_blank" href="https://github.com/panjf2000/gnet"><img src="https://img.shields.io/badge/platform-Linux%20%7C%20FreeBSD%20%7C%20DragonFly%20%7C%20Darwin%20%7C%20Windows-549688?style=flat-square&logo=dlna"></a>
<a title="Require Go Version" target="_blank" href="https://github.com/panjf2000/gnet"><img src="https://img.shields.io/badge/go-%3E%3D1.9-30dff3?style=flat-square&logo=go"></a>
<a title="Release" target="_blank" href="https://github.com/panjf2000/gnet/releases"><img src="https://img.shields.io/github/v/release/panjf2000/gnet.svg?color=161823&style=flat-square&logo=smartthings"></a>
<br/>
<a title="Go Report Card" target="_blank" href="https://goreportcard.com/report/github.com/panjf2000/gnet"><img src="https://goreportcard.com/badge/github.com/panjf2000/gnet?style=flat-square"></a>
<a title="Doc for gnet" target="_blank" href="https://pkg.go.dev/github.com/panjf2000/gnet?tab=doc"><img src="https://img.shields.io/badge/go.dev-doc-007d9c?style=flat-square&logo=read-the-docs"></a>
<a title="gnet on Sourcegraph" target="_blank" href="https://sourcegraph.com/github.com/panjf2000/gnet?badge"><img src="https://sourcegraph.com/github.com/panjf2000/gnet/-/badge.svg?style=flat-square"></a>
<a title="Mentioned in Awesome Go" target="_blank" href="https://github.com/avelino/awesome-go#networking"><img src="https://awesome.re/mentioned-badge-flat.svg"></a>
<a title="Release" target="_blank" href="https://github.com/panjf2000/gnet/releases"><img src="https://img.shields.io/github/v/release/panjf2000/gnet.svg?color=161823&style=flat-square&logo=smartthings"></a>
</p>

English | [🇨🇳中文](README_ZH.md)
Expand Down
4 changes: 2 additions & 2 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<br />
<a title="Build Status" target="_blank" href="https://travis-ci.com/panjf2000/gnet"><img src="https://img.shields.io/travis/com/panjf2000/gnet?style=flat-square&logo=travis-ci&logoColor=white"></a>
<a title="Codecov" target="_blank" href="https://codecov.io/gh/panjf2000/gnet"><img src="https://img.shields.io/codecov/c/github/panjf2000/gnet?style=flat-square&logo=codecov"></a>
<a title="Supported Platforms" target="_blank" href="https://github.com/panjf2000/gnet"><img src="https://img.shields.io/badge/platform-Linux%20%7C%20FreeBSD%20%7C%20Darwin%20%7C%20Windows-549688?style=flat-square&logo=dlna"></a>
<a title="Supported Platforms" target="_blank" href="https://github.com/panjf2000/gnet"><img src="https://img.shields.io/badge/platform-Linux%20%7C%20FreeBSD%20%7C%20DragonFly%20%7C%20Darwin%20%7C%20Windows-549688?style=flat-square&logo=dlna"></a>
<a title="Require Go Version" target="_blank" href="https://github.com/panjf2000/gnet"><img src="https://img.shields.io/badge/go-%3E%3D1.9-30dff3?style=flat-square&logo=go"></a>
<a title="Release" target="_blank" href="https://github.com/panjf2000/gnet/releases"><img src="https://img.shields.io/github/v/release/panjf2000/gnet.svg?color=161823&style=flat-square&logo=smartthings"></a>
<br/>
<a title="Go Report Card" target="_blank" href="https://goreportcard.com/report/github.com/panjf2000/gnet"><img src="https://goreportcard.com/badge/github.com/panjf2000/gnet?style=flat-square"></a>
<a title="Doc for gnet" target="_blank" href="https://pkg.go.dev/github.com/panjf2000/gnet?tab=doc"><img src="https://img.shields.io/badge/go.dev-doc-007d9c?style=flat-square&logo=read-the-docs"></a>
<a title="gnet on Sourcegraph" target="_blank" href="https://sourcegraph.com/github.com/panjf2000/gnet?badge"><img src="https://sourcegraph.com/github.com/panjf2000/gnet/-/badge.svg?style=flat-square"></a>
<a title="Mentioned in Awesome Go" target="_blank" href="https://github.com/avelino/awesome-go#networking"><img src="https://awesome.re/mentioned-badge-flat.svg"></a>
<a title="Release" target="_blank" href="https://github.com/panjf2000/gnet/releases"><img src="https://img.shields.io/github/v/release/panjf2000/gnet.svg?color=161823&style=flat-square&logo=smartthings"></a>
</p>

[英文](README.md) | 🇨🇳中文
Expand Down
2 changes: 1 addition & 1 deletion acceptor_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

// +build linux darwin netbsd freebsd openbsd dragonfly
// +build linux freebsd dragonfly darwin

package gnet

Expand Down
2 changes: 0 additions & 2 deletions acceptor_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

// +build windows

package gnet

import (
Expand Down
2 changes: 1 addition & 1 deletion connection_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

// +build linux darwin netbsd freebsd openbsd dragonfly
// +build linux freebsd dragonfly darwin

package gnet

Expand Down
2 changes: 0 additions & 2 deletions connection_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

// +build windows

package gnet

import (
Expand Down
2 changes: 1 addition & 1 deletion eventloop_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

// +build linux darwin netbsd freebsd openbsd dragonfly
// +build linux freebsd dragonfly darwin

package gnet

Expand Down
2 changes: 0 additions & 2 deletions eventloop_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

// +build windows

package gnet

import (
Expand Down
2 changes: 1 addition & 1 deletion internal/netpoll/kqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

// +build darwin netbsd freebsd openbsd dragonfly
// +build freebsd dragonfly darwin

package netpoll

Expand Down
2 changes: 1 addition & 1 deletion internal/netpoll/kqueue_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

// +build darwin netbsd freebsd openbsd dragonfly
// +build freebsd dragonfly darwin

package netpoll

Expand Down
29 changes: 0 additions & 29 deletions internal/netpoll/netpoll_stub.go

This file was deleted.

2 changes: 1 addition & 1 deletion internal/netpoll/netpoll_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

// +build linux netbsd freebsd dragonfly
// +build linux freebsd dragonfly

package netpoll

Expand Down
2 changes: 1 addition & 1 deletion internal/netpoll/socktoaddr.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

// +build linux darwin netbsd freebsd openbsd dragonfly
// +build linux freebsd dragonfly darwin

package netpoll

Expand Down
2 changes: 1 addition & 1 deletion internal/reuseport/reuseport.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// Package reuseport provides a function that returns fd and net.Listener powered
// by a net.FileListener with a SO_REUSEPORT option set to the socket.

// +build linux darwin netbsd freebsd openbsd dragonfly
// +build linux freebsd dragonfly darwin

package reuseport

Expand Down
6 changes: 1 addition & 5 deletions internal/reuseport/reuseport_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// +build darwin netbsd freebsd openbsd dragonfly
// +build freebsd dragonfly darwin

package reuseport

Expand All @@ -34,10 +34,6 @@ func maxListenerBacklog() int {
n, err = unix.SysctlUint32("kern.ipc.somaxconn")
case "freebsd":
n, err = unix.SysctlUint32("kern.ipc.soacceptqueue")
case "netbsd":
// NOTE: NetBSD has no somaxconn-like kernel state so far
case "openbsd":
n, err = unix.SysctlUint32("kern.somaxconn")
}
if n == 0 || err != nil {
return unix.SOMAXCONN
Expand Down
2 changes: 1 addition & 1 deletion internal/reuseport/sock_cloexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// +build linux netbsd freebsd openbsd dragonfly
// +build linux freebsd dragonfly

package reuseport

Expand Down
2 changes: 1 addition & 1 deletion internal/reuseport/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// +build linux darwin netbsd freebsd openbsd dragonfly
// +build linux freebsd dragonfly darwin

package reuseport

Expand Down
2 changes: 1 addition & 1 deletion internal/reuseport/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// +build linux darwin netbsd freebsd openbsd dragonfly
// +build linux freebsd dragonfly darwin

package reuseport

Expand Down
2 changes: 1 addition & 1 deletion internal/reuseport/uds.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// +build linux darwin netbsd freebsd openbsd dragonfly
// +build linux freebsd dragonfly darwin

package reuseport

Expand Down
2 changes: 1 addition & 1 deletion listener_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

// +build linux darwin netbsd freebsd openbsd dragonfly
// +build linux freebsd dragonfly darwin

package gnet

Expand Down
2 changes: 0 additions & 2 deletions listener_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

// +build windows

package gnet

import (
Expand Down
2 changes: 1 addition & 1 deletion loop_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

// +build darwin netbsd freebsd openbsd dragonfly
// +build freebsd dragonfly darwin

package gnet

Expand Down
2 changes: 1 addition & 1 deletion reactor_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

// +build darwin netbsd freebsd openbsd dragonfly
// +build freebsd dragonfly darwin

package gnet

Expand Down
18 changes: 10 additions & 8 deletions server_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

// +build !darwin,!netbsd,!freebsd,!openbsd,!dragonfly,!linux,!windows
// +build !linux,!freebsd,!dragonfly,!darwin,!windows

package gnet

import "net"

type server struct {
subEventLoopSet loadBalancer // event-loops for handling events
}
Expand All @@ -18,19 +16,23 @@ type eventloop struct {
}

type listener struct {
ln net.Listener
pconn net.PacketConn
lnaddr net.Addr
reusePort bool
addr, network string
}

func (ln *listener) renormalize() error {
func (ln *listener) normalize() error {
return nil
}

func (ln *listener) close() {
}

func serve(eventHandler EventHandler, listeners *listener, options *Options) error {
func initListener(network, addr string, reusePort bool) (l *listener, err error) {
l = &listener{network: network, addr: addr, reusePort: reusePort}
err = l.normalize()
return
}

func serve(_ EventHandler, _ *listener, _ *Options) error {
return ErrUnsupportedPlatform
}
2 changes: 1 addition & 1 deletion server_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

// +build linux darwin netbsd freebsd openbsd dragonfly
// +build linux freebsd dragonfly darwin

package gnet

Expand Down
2 changes: 0 additions & 2 deletions server_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

// +build windows

package gnet

import (
Expand Down

0 comments on commit 637144b

Please sign in to comment.