Skip to content

Commit

Permalink
follow Standard Go Project Layout
Browse files Browse the repository at this point in the history
https://github.com/golang-standards/project-layout

Now you can see clearly what are private and public library code.

Signed-off-by: FUJITA Tomonori <[email protected]>
  • Loading branch information
fujita committed Jul 7, 2018
1 parent b307975 commit c4775c4
Show file tree
Hide file tree
Showing 111 changed files with 153 additions and 154 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*.a
*.so
*.pyc
gobgp/gobgp
gobgpd/gobgpd
cmd/gobgp/gobgp
cmd/gobgpd/gobgpd

# Folders
_obj
Expand Down
4 changes: 2 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# .goreleaser.yml
# Build customization
builds:
- main: ./gobgp/
- main: ./cmd/gobgp/
binary: gobgp
goos:
- linux
Expand All @@ -12,7 +12,7 @@ builds:
- arm
- arm64

- main: ./gobgpd/
- main: ./cmd/gobgpd/
binary: gobgpd
goos:
- linux
Expand Down
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ _unittest: &_unittest
<<: *_dep_ensure
script:
- go test $(go list ./... | grep -v '/vendor/') -timeout 120s
- if [ "$(go env GOARCH)" = "amd64" ]; then go test -race github.com/osrg/gobgp/packet/bgp -run ^Test_RaceCondition$; else echo 'skip'; fi
- if [ "$(go env GOARCH)" = "amd64" ]; then go test -race github.com/osrg/gobgp/pkg/packet/bgp -run ^Test_RaceCondition$; else echo 'skip'; fi

_build: &_build
<<: *_dep_ensure
script:
- go build -o ./gobgp/gobgp ./gobgp/
- go build -o ./gobgpd/gobgpd ./gobgpd/
- go build -o ./cmd/gobgp/gobgp ./cmd/gobgp/
- go build -o ./cmd/gobgpd/gobgpd ./cmd/gobgpd/

_node_js: &_node_js
language: node_js
Expand Down Expand Up @@ -114,10 +114,10 @@ matrix:
- test -z "$(go fmt $(go list ./... | grep -v '/vendor/'))"
- test -z "$(go vet $(go list ./... | grep -v '/vendor/'))"
- megacheck $(go list ./... | grep -v '/vendor/')
- <<: *_dep_ensure
env:
- DESCRIPTION="build_embeded_go.py"
script: python test/scenario_test/ci-scripts/build_embeded_go.py docs/sources/lib.md
# - <<: *_dep_ensure
# env:
# - DESCRIPTION="build_embeded_go.py"
# script: python test/scenario_test/ci-scripts/build_embeded_go.py docs/sources/lib.md
#
# Docker
#
Expand Down
3 changes: 1 addition & 2 deletions api/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import (
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/any"
"github.com/osrg/gobgp/pkg/packet/bgp"
log "github.com/sirupsen/logrus"

"github.com/osrg/gobgp/packet/bgp"
)

func NewOriginAttributeFromNative(a *bgp.PathAttributeOrigin) *OriginAttribute {
Expand Down
3 changes: 1 addition & 2 deletions api/attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ import (
"net"
"testing"

"github.com/osrg/gobgp/packet/bgp"

"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/any"
"github.com/osrg/gobgp/pkg/packet/bgp"
"github.com/stretchr/testify/assert"
)

Expand Down
3 changes: 1 addition & 2 deletions api/capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import (
proto "github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/any"

"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/pkg/packet/bgp"
)

func NewMultiProtocolCapability(a *bgp.CapMultiProtocol) *MultiProtocolCapability {
Expand Down
3 changes: 1 addition & 2 deletions api/capability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ package gobgpapi
import (
"testing"

"github.com/osrg/gobgp/pkg/packet/bgp"
"github.com/stretchr/testify/assert"

"github.com/osrg/gobgp/packet/bgp"
)

func Test_MultiProtocolCapability(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"net"
"time"

"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/pkg/packet/bgp"
)

func getNLRI(family bgp.RouteFamily, buf []byte) (bgp.AddrPrefixInterface, error) {
Expand Down
5 changes: 2 additions & 3 deletions gobgp/cmd/bmp.go → cmd/gobgp/cmd/bmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ import (
"net"
"strconv"

"github.com/osrg/gobgp/internal/pkg/config"
"github.com/osrg/gobgp/pkg/packet/bmp"
"github.com/spf13/cobra"

"github.com/osrg/gobgp/config"
"github.com/osrg/gobgp/packet/bmp"
)

func modBmpServer(cmdType string, args []string) error {
Expand Down
6 changes: 3 additions & 3 deletions gobgp/cmd/common.go → cmd/gobgp/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import (
"google.golang.org/grpc/credentials"

api "github.com/osrg/gobgp/api"
cli "github.com/osrg/gobgp/client"
"github.com/osrg/gobgp/config"
"github.com/osrg/gobgp/packet/bgp"
cli "github.com/osrg/gobgp/internal/pkg/client"
"github.com/osrg/gobgp/internal/pkg/config"
"github.com/osrg/gobgp/pkg/packet/bgp"
)

const (
Expand Down
File renamed without changes.
7 changes: 4 additions & 3 deletions gobgp/cmd/global.go → cmd/gobgp/cmd/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ import (
"github.com/spf13/cobra"

api "github.com/osrg/gobgp/api"
"github.com/osrg/gobgp/config"
"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/table"
"github.com/osrg/gobgp/internal/pkg/config"
"github.com/osrg/gobgp/internal/pkg/table"

"github.com/osrg/gobgp/pkg/packet/bgp"
)

type ExtCommType int
Expand Down
3 changes: 1 addition & 2 deletions gobgp/cmd/global_test.go → cmd/gobgp/cmd/global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import (
"strings"
"testing"

"github.com/osrg/gobgp/pkg/packet/bgp"
"github.com/stretchr/testify/assert"

"github.com/osrg/gobgp/packet/bgp"
)

func Test_ParsePath(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion gobgp/cmd/monitor.go → cmd/gobgp/cmd/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/spf13/cobra"

api "github.com/osrg/gobgp/api"
"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/pkg/packet/bgp"
)

func makeMonitorRouteArgs(p *api.Path, showIdentifier bgp.BGPAddPathMode) []interface{} {
Expand Down
4 changes: 2 additions & 2 deletions gobgp/cmd/mrt.go → cmd/gobgp/cmd/mrt.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"github.com/spf13/cobra"

api "github.com/osrg/gobgp/api"
"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/packet/mrt"
"github.com/osrg/gobgp/pkg/packet/bgp"
"github.com/osrg/gobgp/pkg/packet/mrt"
)

func injectMrt() error {
Expand Down
5 changes: 2 additions & 3 deletions gobgp/cmd/neighbor.go → cmd/gobgp/cmd/neighbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ import (

"github.com/spf13/cobra"

"github.com/osrg/gobgp/config"
"github.com/osrg/gobgp/packet/bgp"

api "github.com/osrg/gobgp/api"
"github.com/osrg/gobgp/internal/pkg/config"
"github.com/osrg/gobgp/pkg/packet/bgp"
)

// used in showRoute() to determine the width of each column
Expand Down
4 changes: 2 additions & 2 deletions gobgp/cmd/policy.go → cmd/gobgp/cmd/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/spf13/cobra"

api "github.com/osrg/gobgp/api"
"github.com/osrg/gobgp/config"
"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/internal/pkg/config"
"github.com/osrg/gobgp/pkg/packet/bgp"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion gobgp/cmd/root.go → cmd/gobgp/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"net/http"
_ "net/http/pprof"

cli "github.com/osrg/gobgp/client"
cli "github.com/osrg/gobgp/internal/pkg/client"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion gobgp/cmd/rpki.go → cmd/gobgp/cmd/rpki.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"net"
"time"

"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/pkg/packet/bgp"
"github.com/spf13/cobra"
)

Expand Down
5 changes: 2 additions & 3 deletions gobgp/cmd/rpki_test.go → cmd/gobgp/cmd/rpki_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ import (
"testing"
"time"

"github.com/osrg/gobgp/internal/pkg/config"
"github.com/osrg/gobgp/pkg/server"
"github.com/stretchr/testify/assert"

"github.com/osrg/gobgp/config"
"github.com/osrg/gobgp/server"
)

func TestShowRPKITable(test *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion gobgp/cmd/vrf.go → cmd/gobgp/cmd/vrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"strings"

api "github.com/osrg/gobgp/api"
"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/pkg/packet/bgp"

"github.com/golang/protobuf/ptypes/any"
"github.com/spf13/cobra"
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions gobgp/lib/path.go → cmd/gobgp/lib/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import (
"encoding/json"
"strings"

"github.com/osrg/gobgp/gobgp/cmd"
"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/cmd/gobgp/cmd"
"github.com/osrg/gobgp/pkg/packet/bgp"
)

//export get_route_family
Expand Down
5 changes: 3 additions & 2 deletions gobgp/main.go → cmd/gobgp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ package main

import (
"fmt"
"github.com/osrg/gobgp/gobgp/cmd"
"google.golang.org/grpc"
"os"

"github.com/osrg/gobgp/cmd/gobgp/cmd"
"google.golang.org/grpc"
)

var version = "master"
Expand Down
8 changes: 4 additions & 4 deletions gobgpd/main.go → cmd/gobgpd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ import (
"google.golang.org/grpc/credentials"

api "github.com/osrg/gobgp/api"
"github.com/osrg/gobgp/config"
"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/server"
"github.com/osrg/gobgp/table"
"github.com/osrg/gobgp/internal/pkg/config"
"github.com/osrg/gobgp/internal/pkg/table"
"github.com/osrg/gobgp/pkg/packet/bgp"
"github.com/osrg/gobgp/pkg/server"
)

var version = "master"
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions client/client.go → internal/pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
"google.golang.org/grpc"

api "github.com/osrg/gobgp/api"
"github.com/osrg/gobgp/config"
"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/server"
"github.com/osrg/gobgp/internal/pkg/config"
"github.com/osrg/gobgp/pkg/packet/bgp"
"github.com/osrg/gobgp/pkg/server"
)

type Client struct {
Expand Down
4 changes: 2 additions & 2 deletions client/client_test.go → internal/pkg/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"testing"
"time"

"github.com/osrg/gobgp/config"
"github.com/osrg/gobgp/server"
"github.com/osrg/gobgp/internal/pkg/config"
"github.com/osrg/gobgp/pkg/server"
"github.com/stretchr/testify/assert"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package config
import (
"fmt"

"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/pkg/packet/bgp"
)

func mapkey(index int, name string) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestConfigExample(t *testing.T) {
assert := assert.New(t)

_, f, _, _ := runtime.Caller(0)
fileMd := path.Join(path.Dir(f), "../docs/sources/configuration.md")
fileMd := path.Join(path.Dir(f), "../../../docs/sources/configuration.md")
fileToml := "/tmp/gobgpd.example.toml"
assert.NoError(extractTomlFromMarkdown(fileMd, fileToml))
defer os.Remove(fileToml)
Expand Down
7 changes: 3 additions & 4 deletions config/default.go → internal/pkg/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import (
"reflect"
"strconv"

"github.com/osrg/gobgp/pkg/packet/bgp"
"github.com/osrg/gobgp/pkg/packet/bmp"
"github.com/osrg/gobgp/pkg/packet/rtr"
"github.com/spf13/viper"

"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/packet/bmp"
"github.com/osrg/gobgp/packet/rtr"
)

const (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion config/util.go → internal/pkg/config/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"regexp"
"strconv"

"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/pkg/packet/bgp"
)

// Returns config file type by retrieving extension from the given path.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion table/adj.go → internal/pkg/table/adj.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package table
import (
"fmt"

"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/pkg/packet/bgp"
)

type AdjRib struct {
Expand Down
3 changes: 2 additions & 1 deletion table/adj_test.go → internal/pkg/table/adj_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import (
"testing"
"time"

"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/pkg/packet/bgp"

"github.com/stretchr/testify/assert"
)

Expand Down
6 changes: 3 additions & 3 deletions table/destination.go → internal/pkg/table/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (
"net"
"sort"

log "github.com/sirupsen/logrus"
"github.com/osrg/gobgp/internal/pkg/config"
"github.com/osrg/gobgp/pkg/packet/bgp"

"github.com/osrg/gobgp/config"
"github.com/osrg/gobgp/packet/bgp"
log "github.com/sirupsen/logrus"
)

var SelectionOptions config.RouteSelectionOptionsConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import (
"testing"
"time"

"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/pkg/packet/bgp"

"github.com/stretchr/testify/assert"
)

Expand Down
Loading

0 comments on commit c4775c4

Please sign in to comment.