This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-cli.git


The following commit(s) were added to refs/heads/master by this push:
     new b3b919d  chore: reorganize the project layout and add an example of 
.skywalking.yaml (#82)
b3b919d is described below

commit b3b919d5c89d43aebfc6f25f147bf41db11950bf
Author: Zhenxu Ke <[email protected]>
AuthorDate: Sat Dec 19 21:30:46 2020 +0800

    chore: reorganize the project layout and add an example of .skywalking.yaml 
(#82)
---
 .github/workflows/go.yml                           |  8 +-
 CONTRIBUTING.md                                    | 12 +--
 Makefile                                           | 12 +--
 README.md                                          |  6 +-
 {graphql/schema => api}/schema.go                  |  2 +-
 assets/assets.gen.go                               | 20 ++---
 assets/assets.go                                   |  2 +-
 .../healthcheck.graphql}                           |  0
 cmd/{ => swctl}/main.go                            | 22 ++---
 .../.skywalking.yaml                               |  9 +-
 {example => examples}/global.yml                   |  0
 go.mod                                             |  3 +-
 go.sum                                             | 33 +++++++-
 gqlgen.yml                                         |  6 +-
 .../commands}/dashboard/dashboard.go               |  2 +-
 .../commands}/dashboard/global/global.go           | 21 +++--
 .../commands}/dashboard/global/metrics.go          | 23 +++--
 .../commands}/endpoint/endpoint.go                 |  0
 {commands => internal/commands}/endpoint/list.go   | 14 ++-
 .../commands/healthcheck/healthcheck.go            | 18 ++--
 .../commands}/instance/instance.go                 |  4 +-
 {commands => internal/commands}/instance/list.go   | 22 +++--
 {commands => internal/commands}/instance/search.go | 24 ++++--
 .../commands}/interceptor/duration.go              | 15 ++--
 .../commands}/interceptor/duration_test.go         | 12 +--
 .../commands}/interceptor/entity.go                | 24 +++---
 .../commands}/interceptor/entity_test.go           | 34 ++++----
 .../commands}/interceptor/interceptor.go           |  0
 .../commands}/interceptor/timezone.go              |  4 +-
 .../commands}/metrics/aggregation/topn.go          | 30 ++++---
 .../commands}/metrics/linear/linear-metrics.go     | 25 +++---
 .../metrics/linear/multiple-linear-metrics.go      | 28 +++---
 .../commands}/metrics/list/list-metrics.go         | 14 ++-
 {commands => internal/commands}/metrics/metrics.go | 10 +--
 .../commands}/metrics/single/single-metrics.go     | 25 +++---
 .../metrics/thermodynamic/thermodynamic.go         | 25 +++---
 {commands => internal/commands}/service/list.go    | 31 ++++---
 {commands => internal/commands}/service/service.go |  0
 {commands => internal/commands}/trace/list.go      | 36 ++++----
 {commands => internal/commands}/trace/trace.go     | 14 ++-
 {commands => internal}/flags/duration.go           | 13 +--
 {commands => internal}/flags/entity.go             |  0
 {commands => internal}/flags/flags.go              |  0
 {commands => internal}/flags/instance.go           |  0
 {commands => internal}/flags/metrics.go            | 12 +--
 {commands => internal}/flags/search.go             |  0
 {logger => internal/logger}/log.go                 |  0
 {commands => internal}/model/order.go              | 12 +--
 {commands => internal}/model/scope.go              | 12 +--
 {commands => internal}/model/step.go               | 12 +--
 {display => pkg/display}/display.go                | 10 +--
 .../display}/displayable/displayable.go            |  6 +-
 {display => pkg/display}/graph/dashboard/global.go | 35 ++++----
 {display => pkg/display}/graph/gauge/gauge.go      | 19 +++--
 {display => pkg/display}/graph/graph.go            | 25 +++---
 {display => pkg/display}/graph/heatmap/heatmap.go  | 17 ++--
 {display => pkg/display}/graph/linear/linear.go    |  0
 {display => pkg/display}/graph/tree/adapter.go     | 29 ++++---
 {display => pkg/display}/graph/tree/list.go        | 41 ++++++---
 {display => pkg/display}/graph/tree/tree.go        |  2 +-
 {display => pkg/display}/json/json.go              |  2 +-
 {display => pkg/display}/json/json_test.go         | 12 +--
 {display => pkg/display}/table/table.go            |  4 +-
 {display => pkg/display}/table/table_test.go       | 12 +--
 {display => pkg/display}/yaml/yaml.go              |  2 +-
 {display => pkg/display}/yaml/yaml_test.go         | 12 +--
 {graphql => pkg/graphql}/client/client.go          |  9 +-
 {graphql => pkg/graphql}/dashboard/global.go       | 99 ++++++++++++++--------
 .../graphql/healthcheck/healthcheck.go             | 17 ++--
 {graphql => pkg/graphql}/metadata/metadata.go      | 44 +++++-----
 {graphql => pkg/graphql}/metrics/metrics.go        | 54 ++++++------
 {graphql => pkg/graphql}/trace/trace.go            | 21 ++---
 {graphql => pkg/graphql}/utils/adapter.go          | 13 +--
 {graphql => pkg/graphql}/utils/adapter_test.go     | 16 ++--
 {graphql => pkg/graphql}/utils/constants.go        | 22 ++---
 grpc/health.go => pkg/healthcheck/grpc.go          |  4 +-
 {lib => pkg}/heatmap/axes/axes.go                  |  0
 {lib => pkg}/heatmap/axes/label.go                 |  0
 {lib => pkg}/heatmap/heatmap.go                    |  2 +-
 {lib => pkg}/heatmap/options.go                    |  0
 {util => pkg/util}/io.go                           |  2 +-
 {util => pkg/util}/lang.go                         |  0
 {util => pkg/util}/math.go                         |  0
 {hack => scripts}/boilerplate.go.txt               |  0
 {hack => scripts}/build-header.sh                  |  0
 {test => scripts}/test_commands.sh                 |  0
 86 files changed, 676 insertions(+), 506 deletions(-)

diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index 4bab776..6d1bc2d 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -27,10 +27,10 @@ jobs:
     name: Build
     runs-on: ubuntu-latest
     steps:
-      - name: Set up Go 1.13
-        uses: actions/setup-go@v1
+      - name: Set up Go 1.14
+        uses: actions/setup-go@v2
         with:
-          go-version: 1.13
+          go-version: 1.14
         id: go
 
       - name: Check out code into the Go module directory
@@ -63,4 +63,4 @@ jobs:
         run: make build -j3
 
       - name: Test commands
-        run: make test-commands
\ No newline at end of file
+        run: make test-commands
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 9688f0d..6a9d939 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -47,17 +47,17 @@ make
 ```
 
 ## Writing a new command
-All commands files locate in directory [`commands`](commands), and an 
individual directory for each second-level command,
-an individual `go` file for each third-level command, for example, there is a 
directory [`service`](commands/service) for command `swctl service`, 
-and a [`list.go`](commands/service/list.go) file for `swctl service list` 
command.
+All commands files locate in directory [`commands`](internal/commands), and an 
individual directory for each second-level command,
+an individual `go` file for each third-level command, for example, there is a 
directory [`service`](internal/commands/service) for command `swctl service`, 
+and a [`list.go`](internal/commands/service/list.go) file for `swctl service 
list` command.
 
 Determine what entity your command will operate on, and put your command `go` 
file into that directory, or create one if it doesn't exist,
 for example, if you want to create a command to `list` all the `instance`s of 
a service, create a directory `commands/instance`,
 and a `go` file `commands/instance/list.go`.
 
 ## Reusing common options
-There're some [common options](#common-options) that can be shared by multiple 
commands, check [`commands/flags`](commands/flags)
-to get all the shared options, and reuse them when possible, an example shares 
the options is [`commands/service/list.go`](commands/service/list.go#L35)
+There're some [common options](#common-options) that can be shared by multiple 
commands, check [`commands/flags`](internal/flags)
+to get all the shared options, and reuse them when possible, an example shares 
the options is 
[`commands/service/list.go`](internal/commands/service/list.go#L35)
 
 ## Linting your codes
 We have some rules for the code style and please lint your codes locally 
before opening a pull request
@@ -99,4 +99,4 @@ This section guides committers and PMC members to release 
SkyWalking CLI in Apac
 - [Send internal 
announcement](docs/How-to-release.md#make-the-internal-announcements)
 - [Wait at least 48 hours for test 
responses](docs/How-to-release.md#wait-at-least-48-hours-for-test-responses)
 - [Call for vote](docs/How-to-release.md#call-a-vote-in-dev)
-- [Publish release](docs/How-to-release.md#publish-release)
\ No newline at end of file
+- [Publish release](docs/How-to-release.md#publish-release)
diff --git a/Makefile b/Makefile
index e8017d5..d063a07 100644
--- a/Makefile
+++ b/Makefile
@@ -51,7 +51,7 @@ tools:
        mkdir -p $(GO_PATH)/bin
        $(GO_BINDATA) -v || curl --location --output $(GO_BINDATA) 
https://github.com/kevinburke/go-bindata/releases/download/$(GOBINDATA_VERSION)/go-bindata-$(OSNAME)-amd64
 \
                && chmod +x $(GO_BINDATA)
-       $(GO_LINT) version || curl -sfL 
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh 
-s -- -b $(GO_PATH)/bin v1.21.0
+       $(GO_LINT) version || curl -sfL 
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh 
-s -- -b $(GO_PATH)/bin
        $(GO_LICENSER) -version || GO111MODULE=off $(GO_GET) -u 
github.com/elastic/go-licenser
        $(GQL_GEN) version || GO111MODULE=off $(GO_GET) -u 
github.com/99designs/gqlgen
 
@@ -63,14 +63,14 @@ assets: tools
        cd assets \
                && $(GO_BINDATA) --nocompress --nometadata --pkg assets 
--ignore '.*\.go' \
                        -o "assets.gen.go" ./... \
-               && ../hack/build-header.sh assets.gen.go \
+               && ../scripts/build-header.sh assets.gen.go \
                && cd ..
 
 gqlgen: tools
        echo 'scalar Long' > query-protocol/schema.graphqls
        $(GQL_GEN) generate
        -rm -rf generated.go
-       -hack/build-header.sh graphql/schema/schema.go
+       -scripts/build-header.sh api/schema.go
        -rm query-protocol/schema.graphqls
        
 codegen: clean assets gqlgen
@@ -79,7 +79,7 @@ codegen: clean assets gqlgen
 .PHONY: $(PLATFORMS)
 $(PLATFORMS):
        mkdir -p $(OUT_DIR)
-       GOOS=$(os) GOARCH=$(ARCH) $(GO_BUILD) $(GO_BUILD_FLAGS) -ldflags 
"$(GO_BUILD_LDFLAGS)" -o $(OUT_DIR)/$(BINARY)-$(VERSION)-$(os)-$(ARCH) 
cmd/main.go
+       GOOS=$(os) GOARCH=$(ARCH) $(GO_BUILD) $(GO_BUILD_FLAGS) -ldflags 
"$(GO_BUILD_LDFLAGS)" -o $(OUT_DIR)/$(BINARY)-$(VERSION)-$(os)-$(ARCH) 
cmd/swctl/main.go
 
 .PHONY: lint
 lint: codegen tools
@@ -163,6 +163,6 @@ test-commands:
                docker container prune -f; \
                docker run --name oap -p 12800:12800 -p 11800:11800 -d -e 
SW_HEALTH_CHECKER=default -e SW_TELEMETRY=prometheus 
apache/skywalking-oap-server:latest; \
        fi
-       ./test/test_commands.sh
+       ./scripts/test_commands.sh
        @docker container stop oap
-       @docker container prune -f
\ No newline at end of file
+       @docker container prune -f
diff --git a/README.md b/README.md
index 0c28b09..5398c77 100644
--- a/README.md
+++ b/README.md
@@ -82,7 +82,7 @@ This section covers all the available commands in SkyWalking 
CLI and their usage
 
 | option | description | default |
 | :--- | :--- | :--- |
-| `--config` | from where the default options values will be loaded | 
`~/.skywalking.yml` |
+| `--config` | from where the default options values will be loaded | 
`~/.skywalking.yml`, example can be found [here](examples/.skywalking.yaml) |
 | `--debug` | enable debug mode, will print more detailed information at 
runtime | `false` |
 | `--base-url` | base url of GraphQL backend | 
`http://127.0.0.1:12800/graphql` |
 | `--username` | username of `Basic` authorization | `` |
@@ -322,7 +322,7 @@ Ascii Graph, like coloring in terminal, so please use 
`json`  or `yaml` instead.
 | `--start` | See [Common options](#common-options) | See [Common 
options](#common-options) |
 | `--end` | See [Common options](#common-options) | See [Common 
options](#common-options) |
 
-You can imitate the content of [the default template file](example/global.yml) 
to customize the dashboard.
+You can imitate the content of [the default template 
file](examples/global.yml) to customize the dashboard.
 
 </details>
 
@@ -341,7 +341,7 @@ You can imitate the content of [the default template 
file](example/global.yml) t
 | `--start` | See [Common options](#common-options) | See [Common 
options](#common-options) |
 | `--end` | See [Common options](#common-options) | See [Common 
options](#common-options) |
 
-You can imitate the content of [the default template file](example/global.yml) 
to customize the dashboard.
+You can imitate the content of [the default template 
file](examples/global.yml) to customize the dashboard.
 
 </details>
 
diff --git a/graphql/schema/schema.go b/api/schema.go
similarity index 99%
rename from graphql/schema/schema.go
rename to api/schema.go
index 8c0b78c..6b45fac 100644
--- a/graphql/schema/schema.go
+++ b/api/schema.go
@@ -17,7 +17,7 @@
 
 // Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
 
-package schema
+package api
 
 import (
        "fmt"
diff --git a/assets/assets.gen.go b/assets/assets.gen.go
index ea21200..ffefe2f 100644
--- a/assets/assets.gen.go
+++ b/assets/assets.gen.go
@@ -17,7 +17,7 @@
 
 // Code generated by go-bindata. DO NOT EDIT.
 // sources:
-// graphqls/common/checkHealth.graphql (870B)
+// graphqls/healthcheck/healthcheck.graphql (870B)
 // graphqls/metadata/AllServices.graphql (911B)
 // graphqls/metadata/Instances.graphql (1.069kB)
 // graphqls/metadata/SearchEndpoints.graphql (975B)
@@ -77,7 +77,7 @@ func (fi bindataFileInfo) Sys() interface{} {
        return nil
 }
 
-var _graphqlsCommonCheckhealthGraphql = []byte(`# Licensed to Apache Software 
Foundation (ASF) under one or more contributor
+var _graphqlsHealthcheckHealthcheckGraphql = []byte(`# Licensed to Apache 
Software Foundation (ASF) under one or more contributor
 # license agreements. See the NOTICE file distributed with
 # this work for additional information regarding copyright
 # ownership. Apache Software Foundation (ASF) licenses this file to you under
@@ -102,17 +102,17 @@ query {
 }
 `)
 
-func graphqlsCommonCheckhealthGraphqlBytes() ([]byte, error) {
-       return _graphqlsCommonCheckhealthGraphql, nil
+func graphqlsHealthcheckHealthcheckGraphqlBytes() ([]byte, error) {
+       return _graphqlsHealthcheckHealthcheckGraphql, nil
 }
 
-func graphqlsCommonCheckhealthGraphql() (*asset, error) {
-       bytes, err := graphqlsCommonCheckhealthGraphqlBytes()
+func graphqlsHealthcheckHealthcheckGraphql() (*asset, error) {
+       bytes, err := graphqlsHealthcheckHealthcheckGraphqlBytes()
        if err != nil {
                return nil, err
        }
 
-       info := bindataFileInfo{name: "graphqls/common/checkHealth.graphql", 
size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)}
+       info := bindataFileInfo{name: 
"graphqls/healthcheck/healthcheck.graphql", size: 0, mode: os.FileMode(0), 
modTime: time.Unix(0, 0)}
        a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc0, 0x71, 
0x53, 0x13, 0xd0, 0x51, 0xd7, 0x12, 0xd1, 0xed, 0xd9, 0x34, 0x17, 0xef, 0x22, 
0xf8, 0xa0, 0xa2, 0x35, 0x57, 0xb, 0x54, 0x6d, 0x5a, 0xb1, 0x8f, 0xbd, 0xb3, 
0x40, 0x34, 0xc2, 0x2d}}
        return a, nil
 }
@@ -884,7 +884,7 @@ func AssetNames() []string {
 
 // _bindata is a table, holding each asset generator, mapped to its name.
 var _bindata = map[string]func() (*asset, error){
-       "graphqls/common/checkHealth.graphql":           
graphqlsCommonCheckhealthGraphql,
+       "graphqls/healthcheck/healthcheck.graphql":      
graphqlsHealthcheckHealthcheckGraphql,
        "graphqls/metadata/AllServices.graphql":         
graphqlsMetadataAllservicesGraphql,
        "graphqls/metadata/Instances.graphql":           
graphqlsMetadataInstancesGraphql,
        "graphqls/metadata/SearchEndpoints.graphql":     
graphqlsMetadataSearchendpointsGraphql,
@@ -946,8 +946,8 @@ type bintree struct {
 
 var _bintree = &bintree{nil, map[string]*bintree{
        "graphqls": &bintree{nil, map[string]*bintree{
-               "common": &bintree{nil, map[string]*bintree{
-                       "checkHealth.graphql": 
&bintree{graphqlsCommonCheckhealthGraphql, map[string]*bintree{}},
+               "healthcheck": &bintree{nil, map[string]*bintree{
+                       "healthcheck.graphql": 
&bintree{graphqlsHealthcheckHealthcheckGraphql, map[string]*bintree{}},
                }},
                "metadata": &bintree{nil, map[string]*bintree{
                        "AllServices.graphql":     
&bintree{graphqlsMetadataAllservicesGraphql, map[string]*bintree{}},
diff --git a/assets/assets.go b/assets/assets.go
index 8983ff9..665e0c3 100644
--- a/assets/assets.go
+++ b/assets/assets.go
@@ -18,7 +18,7 @@
 package assets
 
 import (
-       "github.com/apache/skywalking-cli/logger"
+       "github.com/apache/skywalking-cli/internal/logger"
 )
 
 // Read reads all content from a file under assets, which is packed in to the 
binary
diff --git a/assets/graphqls/common/checkHealth.graphql 
b/assets/graphqls/healthcheck/healthcheck.graphql
similarity index 100%
copy from assets/graphqls/common/checkHealth.graphql
copy to assets/graphqls/healthcheck/healthcheck.graphql
diff --git a/cmd/main.go b/cmd/swctl/main.go
similarity index 85%
rename from cmd/main.go
rename to cmd/swctl/main.go
index 189bd5a..46c7acb 100644
--- a/cmd/main.go
+++ b/cmd/swctl/main.go
@@ -21,24 +21,24 @@ import (
        "io/ioutil"
        "os"
 
-       "github.com/apache/skywalking-cli/commands/common"
-       "github.com/apache/skywalking-cli/commands/trace"
+       "github.com/apache/skywalking-cli/internal/commands/healthcheck"
+       "github.com/apache/skywalking-cli/internal/commands/trace"
 
-       "github.com/apache/skywalking-cli/commands/dashboard"
+       "github.com/apache/skywalking-cli/internal/commands/dashboard"
 
-       "github.com/apache/skywalking-cli/commands/metrics"
+       "github.com/apache/skywalking-cli/internal/commands/metrics"
 
-       "github.com/apache/skywalking-cli/commands/endpoint"
-       "github.com/apache/skywalking-cli/commands/instance"
+       "github.com/apache/skywalking-cli/internal/commands/endpoint"
+       "github.com/apache/skywalking-cli/internal/commands/instance"
 
        "github.com/sirupsen/logrus"
        "github.com/urfave/cli"
        "github.com/urfave/cli/altsrc"
 
-       "github.com/apache/skywalking-cli/commands/interceptor"
-       "github.com/apache/skywalking-cli/commands/service"
-       "github.com/apache/skywalking-cli/logger"
-       "github.com/apache/skywalking-cli/util"
+       "github.com/apache/skywalking-cli/internal/commands/interceptor"
+       "github.com/apache/skywalking-cli/internal/commands/service"
+       "github.com/apache/skywalking-cli/internal/logger"
+       "github.com/apache/skywalking-cli/pkg/util"
 )
 
 var log *logrus.Logger
@@ -108,7 +108,7 @@ func main() {
                service.Command,
                metrics.Command,
                trace.Command,
-               common.Command,
+               healthcheck.Command,
                dashboard.Command,
        }
 
diff --git a/assets/graphqls/common/checkHealth.graphql 
b/examples/.skywalking.yaml
similarity index 87%
rename from assets/graphqls/common/checkHealth.graphql
rename to examples/.skywalking.yaml
index 25297f2..04355cd 100644
--- a/assets/graphqls/common/checkHealth.graphql
+++ b/examples/.skywalking.yaml
@@ -15,9 +15,6 @@
 # specific language governing permissions and limitations
 # under the License.
 
-query {
-    checkHealth {
-        score
-        details
-    }
-}
+base-url: http://demo.skywalking.apache.org/graphql
+username: basic-auth-username
+password: basic-auth-password
diff --git a/example/global.yml b/examples/global.yml
similarity index 100%
rename from example/global.yml
rename to examples/global.yml
diff --git a/go.mod b/go.mod
index caf1f12..4dffc4f 100644
--- a/go.mod
+++ b/go.mod
@@ -20,7 +20,8 @@ require (
        github.com/urfave/cli v1.22.1
        golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect
        golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect
-       google.golang.org/grpc v1.24.0
+       google.golang.org/grpc v1.27.0
+       google.golang.org/protobuf v1.25.0 // indirect
        gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
        gopkg.in/yaml.v2 v2.4.0
 )
diff --git a/go.sum b/go.sum
index e44a9b5..1f05b71 100644
--- a/go.sum
+++ b/go.sum
@@ -25,6 +25,7 @@ github.com/beorn7/perks 
v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
 github.com/beorn7/perks v1.0.0/go.mod 
h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
 github.com/bgentry/speakeasy v0.1.0/go.mod 
h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
 github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod 
h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
+github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod 
h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
 github.com/cespare/xxhash v1.1.0/go.mod 
h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
 github.com/client9/misspell v0.3.4/go.mod 
h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
 github.com/coreos/bbolt v1.3.2/go.mod 
h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
@@ -40,6 +41,8 @@ github.com/davecgh/go-spew v1.1.1 
h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
 github.com/davecgh/go-spew v1.1.1/go.mod 
h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod 
h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
 github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod 
h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
+github.com/envoyproxy/go-control-plane 
v0.9.1-0.20191026205805-5f8ba28d4473/go.mod 
h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
+github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod 
h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
 github.com/fatih/color v1.7.0/go.mod 
h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
 github.com/fsnotify/fsnotify v1.4.7 
h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
 github.com/fsnotify/fsnotify v1.4.7/go.mod 
h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
@@ -65,10 +68,21 @@ github.com/golang/protobuf v1.2.0/go.mod 
h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
 github.com/golang/protobuf v1.3.1/go.mod 
h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 github.com/golang/protobuf v1.3.2 
h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
 github.com/golang/protobuf v1.3.2/go.mod 
h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.4.0-rc.1/go.mod 
h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
+github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod 
h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
+github.com/golang/protobuf v1.4.0-rc.2/go.mod 
h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
+github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod 
h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
+github.com/golang/protobuf v1.4.0/go.mod 
h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
+github.com/golang/protobuf v1.4.1 
h1:ZFgWrT+bLgsYPirOnRfKLYJLvssAegOj/hgyMFdJZe0=
+github.com/golang/protobuf v1.4.1/go.mod 
h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
 github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod 
h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
 github.com/google/btree v1.0.0/go.mod 
h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
 github.com/google/go-cmp v0.2.0/go.mod 
h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
 github.com/google/go-cmp v0.3.0/go.mod 
h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.3.1/go.mod 
h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.4.0/go.mod 
h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
+github.com/google/go-cmp v0.5.0/go.mod 
h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/martian v2.1.0+incompatible/go.mod 
h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
 github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod 
h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
 github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod 
h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
@@ -177,6 +191,7 @@ github.com/prometheus/client_golang v0.9.1/go.mod 
h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP
 github.com/prometheus/client_golang v0.9.3/go.mod 
h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
 github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod 
h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
 github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod 
h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod 
h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
 github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod 
h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
 github.com/prometheus/common v0.4.0/go.mod 
h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
 github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod 
h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
@@ -326,6 +341,8 @@ golang.org/x/tools 
v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtn
 golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod 
h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod 
h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod 
h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 
h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod 
h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 google.golang.org/api v0.4.0/go.mod 
h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
 google.golang.org/api v0.7.0/go.mod 
h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
 google.golang.org/api v0.8.0/go.mod 
h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
@@ -346,11 +363,23 @@ google.golang.org/genproto 
v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98
 google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod 
h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
 google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a 
h1:Ob5/580gVHBJZgXnff1cZDbG+xLtMVE5mDRTe+nIsX4=
 google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod 
h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 
h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=
+google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod 
h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
 google.golang.org/grpc v1.19.0/go.mod 
h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
 google.golang.org/grpc v1.20.1/go.mod 
h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
 google.golang.org/grpc v1.21.1/go.mod 
h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
-google.golang.org/grpc v1.24.0 h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s=
-google.golang.org/grpc v1.24.0/go.mod 
h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA=
+google.golang.org/grpc v1.23.0/go.mod 
h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
+google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg=
+google.golang.org/grpc v1.27.0/go.mod 
h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod 
h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
+google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod 
h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
+google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod 
h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
+google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod 
h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
+google.golang.org/protobuf v1.21.0/go.mod 
h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
+google.golang.org/protobuf v1.22.0/go.mod 
h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod 
h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.25.0 
h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
+google.golang.org/protobuf v1.25.0/go.mod 
h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
 gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod 
h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod 
h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod 
h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/gqlgen.yml b/gqlgen.yml
index 81cf26e..c613e5e 100644
--- a/gqlgen.yml
+++ b/gqlgen.yml
@@ -20,9 +20,9 @@ schema:
 skip_validation: true
 
 model:
-  filename: graphql/schema/schema.go
-  package: schema
+  filename: api/schema.go
+  package: api
 
 models:
   Long:
-    model: github.com/99designs/gqlgen/graphql.Int64
\ No newline at end of file
+    model: github.com/99designs/gqlgen/graphql.Int64
diff --git a/commands/dashboard/dashboard.go 
b/internal/commands/dashboard/dashboard.go
similarity index 93%
rename from commands/dashboard/dashboard.go
rename to internal/commands/dashboard/dashboard.go
index cb1c7c7..5d270da 100644
--- a/commands/dashboard/dashboard.go
+++ b/internal/commands/dashboard/dashboard.go
@@ -20,7 +20,7 @@ package dashboard
 import (
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/commands/dashboard/global"
+       "github.com/apache/skywalking-cli/internal/commands/dashboard/global"
 )
 
 var Command = cli.Command{
diff --git a/commands/dashboard/global/global.go 
b/internal/commands/dashboard/global/global.go
similarity index 77%
rename from commands/dashboard/global/global.go
rename to internal/commands/dashboard/global/global.go
index 577abde..dcdf3db 100644
--- a/commands/dashboard/global/global.go
+++ b/internal/commands/dashboard/global/global.go
@@ -20,15 +20,16 @@ package global
 import (
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/commands/model"
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/api"
+       "github.com/apache/skywalking-cli/internal/logger"
 
-       "github.com/apache/skywalking-cli/display/displayable"
+       "github.com/apache/skywalking-cli/internal/model"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
 
-       "github.com/apache/skywalking-cli/commands/flags"
-       "github.com/apache/skywalking-cli/commands/interceptor"
-       "github.com/apache/skywalking-cli/display"
-       "github.com/apache/skywalking-cli/graphql/dashboard"
+       "github.com/apache/skywalking-cli/internal/commands/interceptor"
+       "github.com/apache/skywalking-cli/internal/flags"
+       "github.com/apache/skywalking-cli/pkg/display"
+       "github.com/apache/skywalking-cli/pkg/graphql/dashboard"
 )
 
 var GlobalCommand = cli.Command{
@@ -62,12 +63,16 @@ var GlobalCommand = cli.Command{
                start := ctx.String("start")
                step := ctx.Generic("step")
 
-               globalData := dashboard.Global(ctx, schema.Duration{
+               globalData, err := dashboard.Global(ctx, api.Duration{
                        Start: start,
                        End:   end,
                        Step:  step.(*model.StepEnumValue).Selected,
                })
 
+               if err != nil {
+                       logger.Log.Fatalln(err)
+               }
+
                return display.Display(ctx, &displayable.Displayable{Data: 
globalData})
        },
 }
diff --git a/commands/dashboard/global/metrics.go 
b/internal/commands/dashboard/global/metrics.go
similarity index 75%
rename from commands/dashboard/global/metrics.go
rename to internal/commands/dashboard/global/metrics.go
index d5ffa40..2ad636f 100644
--- a/commands/dashboard/global/metrics.go
+++ b/internal/commands/dashboard/global/metrics.go
@@ -18,15 +18,16 @@
 package global
 
 import (
-       "github.com/apache/skywalking-cli/commands/flags"
-       "github.com/apache/skywalking-cli/commands/interceptor"
-       "github.com/apache/skywalking-cli/commands/model"
-       "github.com/apache/skywalking-cli/display"
-       "github.com/apache/skywalking-cli/display/displayable"
-       "github.com/apache/skywalking-cli/graphql/dashboard"
-       "github.com/apache/skywalking-cli/graphql/schema"
-
        "github.com/urfave/cli"
+
+       "github.com/apache/skywalking-cli/api"
+       "github.com/apache/skywalking-cli/internal/commands/interceptor"
+       "github.com/apache/skywalking-cli/internal/flags"
+       "github.com/apache/skywalking-cli/internal/logger"
+       "github.com/apache/skywalking-cli/internal/model"
+       "github.com/apache/skywalking-cli/pkg/display"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
+       "github.com/apache/skywalking-cli/pkg/graphql/dashboard"
 )
 
 var Metrics = cli.Command{
@@ -52,12 +53,16 @@ var Metrics = cli.Command{
                start := ctx.String("start")
                step := ctx.Generic("step")
 
-               globalMetrics := dashboard.Metrics(ctx, schema.Duration{
+               globalMetrics, err := dashboard.Metrics(ctx, api.Duration{
                        Start: start,
                        End:   end,
                        Step:  step.(*model.StepEnumValue).Selected,
                })
 
+               if err != nil {
+                       logger.Log.Fatalln(err)
+               }
+
                return display.Display(ctx, &displayable.Displayable{Data: 
globalMetrics})
        },
 }
diff --git a/commands/endpoint/endpoint.go 
b/internal/commands/endpoint/endpoint.go
similarity index 100%
rename from commands/endpoint/endpoint.go
rename to internal/commands/endpoint/endpoint.go
diff --git a/commands/endpoint/list.go b/internal/commands/endpoint/list.go
similarity index 83%
rename from commands/endpoint/list.go
rename to internal/commands/endpoint/list.go
index 3c6767b..4c692e3 100644
--- a/commands/endpoint/list.go
+++ b/internal/commands/endpoint/list.go
@@ -20,11 +20,13 @@ package endpoint
 import (
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/display/displayable"
+       "github.com/apache/skywalking-cli/internal/logger"
 
-       "github.com/apache/skywalking-cli/graphql/metadata"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
 
-       "github.com/apache/skywalking-cli/display"
+       "github.com/apache/skywalking-cli/pkg/graphql/metadata"
+
+       "github.com/apache/skywalking-cli/pkg/display"
 )
 
 var ListCommand = cli.Command{
@@ -56,7 +58,11 @@ var ListCommand = cli.Command{
                limit := ctx.Int("limit")
                keyword := ctx.String("keyword")
 
-               endpoints := metadata.SearchEndpoints(ctx, serviceID, keyword, 
limit)
+               endpoints, err := metadata.SearchEndpoints(ctx, serviceID, 
keyword, limit)
+
+               if err != nil {
+                       logger.Log.Fatalln(err)
+               }
 
                return display.Display(ctx, &displayable.Displayable{Data: 
endpoints})
        },
diff --git a/commands/common/common.go 
b/internal/commands/healthcheck/healthcheck.go
similarity index 82%
rename from commands/common/common.go
rename to internal/commands/healthcheck/healthcheck.go
index 7457569..12ab088 100644
--- a/commands/common/common.go
+++ b/internal/commands/healthcheck/healthcheck.go
@@ -15,14 +15,15 @@
 // specific language governing permissions and limitations
 // under the License.
 
-package common
+package healthcheck
 
 import (
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/graphql/common"
-       "github.com/apache/skywalking-cli/grpc"
-       "github.com/apache/skywalking-cli/logger"
+       "github.com/apache/skywalking-cli/pkg/healthcheck"
+
+       "github.com/apache/skywalking-cli/internal/logger"
+       hc "github.com/apache/skywalking-cli/pkg/graphql/healthcheck"
 )
 
 var Command = cli.Command{
@@ -48,7 +49,12 @@ var Command = cli.Command{
                },
        },
        Action: func(ctx *cli.Context) error {
-               healthStatus := common.CheckHealth(ctx)
+               healthStatus, err := hc.CheckHealth(ctx)
+
+               if err != nil {
+                       logger.Log.Fatalln(err)
+               }
+
                if healthStatus.Score != 0 {
                        return cli.NewExitError(healthStatus.Details, 
healthStatus.Score)
                }
@@ -56,7 +62,7 @@ var Command = cli.Command{
                if !ctx.BoolT("grpc") {
                        return nil
                }
-               retCode := grpc.HealthCheck(ctx.String("grpcAddr"), 
ctx.Bool("grpcTLS"))
+               retCode := healthcheck.HealthCheck(ctx.String("grpcAddr"), 
ctx.Bool("grpcTLS"))
                if retCode != 0 {
                        return cli.NewExitError("gRPC: failed to check health", 
retCode)
                }
diff --git a/commands/instance/instance.go 
b/internal/commands/instance/instance.go
similarity index 93%
rename from commands/instance/instance.go
rename to internal/commands/instance/instance.go
index 29c86a7..9277086 100644
--- a/commands/instance/instance.go
+++ b/internal/commands/instance/instance.go
@@ -20,9 +20,9 @@ package instance
 import (
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/graphql/metadata"
+       "github.com/apache/skywalking-cli/pkg/graphql/metadata"
 
-       "github.com/apache/skywalking-cli/logger"
+       "github.com/apache/skywalking-cli/internal/logger"
 )
 
 var Command = cli.Command{
diff --git a/commands/instance/list.go b/internal/commands/instance/list.go
similarity index 74%
rename from commands/instance/list.go
rename to internal/commands/instance/list.go
index 1cfcd88..4318903 100644
--- a/commands/instance/list.go
+++ b/internal/commands/instance/list.go
@@ -20,15 +20,17 @@ package instance
 import (
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/display/displayable"
+       "github.com/apache/skywalking-cli/api"
+       "github.com/apache/skywalking-cli/internal/logger"
 
-       "github.com/apache/skywalking-cli/graphql/metadata"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
 
-       "github.com/apache/skywalking-cli/commands/flags"
-       "github.com/apache/skywalking-cli/commands/interceptor"
-       "github.com/apache/skywalking-cli/commands/model"
-       "github.com/apache/skywalking-cli/display"
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/pkg/graphql/metadata"
+
+       "github.com/apache/skywalking-cli/internal/commands/interceptor"
+       "github.com/apache/skywalking-cli/internal/flags"
+       "github.com/apache/skywalking-cli/internal/model"
+       "github.com/apache/skywalking-cli/pkg/display"
 )
 
 var ListCommand = cli.Command{
@@ -47,12 +49,16 @@ var ListCommand = cli.Command{
                start := ctx.String("start")
                step := ctx.Generic("step")
 
-               instances := metadata.Instances(ctx, serviceID, schema.Duration{
+               instances, err := metadata.Instances(ctx, serviceID, 
api.Duration{
                        Start: start,
                        End:   end,
                        Step:  step.(*model.StepEnumValue).Selected,
                })
 
+               if err != nil {
+                       logger.Log.Fatalln(err)
+               }
+
                return display.Display(ctx, &displayable.Displayable{Data: 
instances})
        },
 }
diff --git a/commands/instance/search.go b/internal/commands/instance/search.go
similarity index 75%
rename from commands/instance/search.go
rename to internal/commands/instance/search.go
index 548606f..ab9cbec 100644
--- a/commands/instance/search.go
+++ b/internal/commands/instance/search.go
@@ -20,17 +20,19 @@ package instance
 import (
        "regexp"
 
-       "github.com/apache/skywalking-cli/display/displayable"
+       "github.com/apache/skywalking-cli/api"
+       "github.com/apache/skywalking-cli/internal/logger"
 
-       "github.com/apache/skywalking-cli/graphql/metadata"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
+
+       "github.com/apache/skywalking-cli/pkg/graphql/metadata"
 
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/commands/flags"
-       "github.com/apache/skywalking-cli/commands/interceptor"
-       "github.com/apache/skywalking-cli/commands/model"
-       "github.com/apache/skywalking-cli/display"
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/internal/commands/interceptor"
+       "github.com/apache/skywalking-cli/internal/flags"
+       "github.com/apache/skywalking-cli/internal/model"
+       "github.com/apache/skywalking-cli/pkg/display"
 )
 
 var SearchCommand = cli.Command{
@@ -50,13 +52,17 @@ var SearchCommand = cli.Command{
 
                regex := ctx.String("regex")
 
-               instances := metadata.Instances(ctx, serviceID, schema.Duration{
+               instances, err := metadata.Instances(ctx, serviceID, 
api.Duration{
                        Start: start,
                        End:   end,
                        Step:  step.(*model.StepEnumValue).Selected,
                })
 
-               var result []schema.ServiceInstance
+               if err != nil {
+                       logger.Log.Fatalln(err)
+               }
+
+               var result []api.ServiceInstance
                if len(instances) > 0 {
                        for _, instance := range instances {
                                if ok, _ := regexp.Match(regex, 
[]byte(instance.Name)); ok {
diff --git a/commands/interceptor/duration.go 
b/internal/commands/interceptor/duration.go
similarity index 91%
rename from commands/interceptor/duration.go
rename to internal/commands/interceptor/duration.go
index 6e382e0..36b83da 100644
--- a/commands/interceptor/duration.go
+++ b/internal/commands/interceptor/duration.go
@@ -21,15 +21,16 @@ import (
        "strconv"
        "time"
 
-       "github.com/apache/skywalking-cli/graphql/utils"
+       "github.com/apache/skywalking-cli/api"
+
+       "github.com/apache/skywalking-cli/pkg/graphql/utils"
 
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/graphql/schema"
-       "github.com/apache/skywalking-cli/logger"
+       "github.com/apache/skywalking-cli/internal/logger"
 )
 
-func TryParseTime(unparsed string) (schema.Step, time.Time, error) {
+func TryParseTime(unparsed string) (api.Step, time.Time, error) {
        var possibleError error = nil
        for step, layout := range utils.StepFormats {
                t, err := time.Parse(layout, unparsed)
@@ -38,7 +39,7 @@ func TryParseTime(unparsed string) (schema.Step, time.Time, 
error) {
                }
                possibleError = err
        }
-       return schema.StepSecond, time.Time{}, possibleError
+       return api.StepSecond, time.Time{}, possibleError
 }
 
 // DurationInterceptor sets the duration if absent, and formats it accordingly,
@@ -70,7 +71,7 @@ func DurationInterceptor(ctx *cli.Context) error {
 //   then: end := now + 30 units, where unit is the precision of `start`, 
(hours, minutes, etc.)
 // if --start is absent, --end is given,
 //   then: start := end - 30 units, where unit is the precision of `end`, 
(hours, minutes, etc.)
-func ParseDuration(start, end, timezone string) (startTime, endTime time.Time, 
step schema.Step, dt utils.DurationType) {
+func ParseDuration(start, end, timezone string) (startTime, endTime time.Time, 
step api.Step, dt utils.DurationType) {
        logger.Log.Debugln("Start time:", start, "end time:", end, "timezone:", 
timezone)
 
        now := time.Now()
@@ -86,7 +87,7 @@ func ParseDuration(start, end, timezone string) (startTime, 
endTime time.Time, s
 
        // both are absent
        if start == "" && end == "" {
-               return now.Add(-30 * time.Minute), now, schema.StepMinute, 
utils.BothAbsent
+               return now.Add(-30 * time.Minute), now, api.StepMinute, 
utils.BothAbsent
        }
 
        var err error
diff --git a/commands/interceptor/duration_test.go 
b/internal/commands/interceptor/duration_test.go
similarity index 94%
rename from commands/interceptor/duration_test.go
rename to internal/commands/interceptor/duration_test.go
index 10c8de5..4af91d0 100644
--- a/commands/interceptor/duration_test.go
+++ b/internal/commands/interceptor/duration_test.go
@@ -22,7 +22,7 @@ import (
        "testing"
        "time"
 
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/api"
 )
 
 func TestParseDuration(t *testing.T) {
@@ -37,7 +37,7 @@ func TestParseDuration(t *testing.T) {
                args            args
                wantedStartTime time.Time
                wantedEndTime   time.Time
-               wantedStep      schema.Step
+               wantedStep      api.Step
        }{
                {
                        name: "Should set current time if start is absent",
@@ -47,7 +47,7 @@ func TestParseDuration(t *testing.T) {
                        },
                        wantedStartTime: now.Add(-30 * time.Minute),
                        wantedEndTime:   now,
-                       wantedStep:      schema.StepMinute,
+                       wantedStep:      api.StepMinute,
                },
                {
                        name: "Should set current time if end is absent",
@@ -57,7 +57,7 @@ func TestParseDuration(t *testing.T) {
                        },
                        wantedStartTime: now,
                        wantedEndTime:   now.Add(30 * time.Minute),
-                       wantedStep:      schema.StepMinute,
+                       wantedStep:      api.StepMinute,
                },
                {
                        name: "Should keep both if both are present",
@@ -67,7 +67,7 @@ func TestParseDuration(t *testing.T) {
                        },
                        wantedStartTime: now.Add(-10 * time.Minute),
                        wantedEndTime:   now.Add(10 * time.Minute),
-                       wantedStep:      schema.StepMinute,
+                       wantedStep:      api.StepMinute,
                },
                {
                        name: "Should set both if both are absent",
@@ -77,7 +77,7 @@ func TestParseDuration(t *testing.T) {
                        },
                        wantedStartTime: now.Add(-30 * time.Minute),
                        wantedEndTime:   now,
-                       wantedStep:      schema.StepMinute,
+                       wantedStep:      api.StepMinute,
                },
        }
        for _, tt := range tests {
diff --git a/commands/interceptor/entity.go 
b/internal/commands/interceptor/entity.go
similarity index 81%
rename from commands/interceptor/entity.go
rename to internal/commands/interceptor/entity.go
index f9544ca..552309a 100644
--- a/commands/interceptor/entity.go
+++ b/internal/commands/interceptor/entity.go
@@ -18,12 +18,12 @@
 package interceptor
 
 import (
-       "github.com/apache/skywalking-cli/graphql/schema"
-
        "github.com/urfave/cli"
+
+       "github.com/apache/skywalking-cli/api"
 )
 
-func ParseEntity(ctx *cli.Context) *schema.Entity {
+func ParseEntity(ctx *cli.Context) *api.Entity {
        service := ctx.String("service")
        normal := ctx.BoolT("isNormal")
        instance := ctx.String("instance")
@@ -34,7 +34,7 @@ func ParseEntity(ctx *cli.Context) *schema.Entity {
        destInstance := ctx.String("destServiceInstance")
        destEndpoint := ctx.String("destEndpoint")
 
-       entity := &schema.Entity{
+       entity := &api.Entity{
                ServiceName:             &service,
                Normal:                  &normal,
                ServiceInstanceName:     &instance,
@@ -50,21 +50,21 @@ func ParseEntity(ctx *cli.Context) *schema.Entity {
 }
 
 // parseScope defines the scope based on the input parameters.
-func parseScope(entity *schema.Entity) schema.Scope {
-       scope := schema.ScopeAll
+func parseScope(entity *api.Entity) api.Scope {
+       scope := api.ScopeAll
 
        if *entity.DestEndpointName != "" {
-               scope = schema.ScopeEndpointRelation
+               scope = api.ScopeEndpointRelation
        } else if *entity.DestServiceInstanceName != "" {
-               scope = schema.ScopeServiceInstanceRelation
+               scope = api.ScopeServiceInstanceRelation
        } else if *entity.DestServiceName != "" {
-               scope = schema.ScopeServiceRelation
+               scope = api.ScopeServiceRelation
        } else if *entity.EndpointName != "" {
-               scope = schema.ScopeEndpoint
+               scope = api.ScopeEndpoint
        } else if *entity.ServiceInstanceName != "" {
-               scope = schema.ScopeServiceInstance
+               scope = api.ScopeServiceInstance
        } else if *entity.ServiceName != "" {
-               scope = schema.ScopeService
+               scope = api.ScopeService
        }
 
        return scope
diff --git a/commands/interceptor/entity_test.go 
b/internal/commands/interceptor/entity_test.go
similarity index 85%
rename from commands/interceptor/entity_test.go
rename to internal/commands/interceptor/entity_test.go
index da3a03a..2f66f52 100644
--- a/commands/interceptor/entity_test.go
+++ b/internal/commands/interceptor/entity_test.go
@@ -20,7 +20,7 @@ package interceptor
 import (
        "testing"
 
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/api"
 )
 
 func Test_parseScope(t *testing.T) {
@@ -28,12 +28,12 @@ func Test_parseScope(t *testing.T) {
        nonEmpty := "test"
        tests := []struct {
                name string
-               args *schema.Entity
-               want schema.Scope
+               args *api.Entity
+               want api.Scope
        }{
                {
                        name: "all of names are empty",
-                       args: &schema.Entity{
+                       args: &api.Entity{
                                ServiceName:             &empty,
                                ServiceInstanceName:     &empty,
                                EndpointName:            &empty,
@@ -41,11 +41,11 @@ func Test_parseScope(t *testing.T) {
                                DestServiceInstanceName: &empty,
                                DestEndpointName:        &empty,
                        },
-                       want: schema.ScopeAll,
+                       want: api.ScopeAll,
                },
                {
                        name: "all of names are not empty",
-                       args: &schema.Entity{
+                       args: &api.Entity{
                                ServiceName:             &nonEmpty,
                                ServiceInstanceName:     &nonEmpty,
                                EndpointName:            &nonEmpty,
@@ -53,11 +53,11 @@ func Test_parseScope(t *testing.T) {
                                DestServiceInstanceName: &nonEmpty,
                                DestEndpointName:        &nonEmpty,
                        },
-                       want: schema.ScopeEndpointRelation,
+                       want: api.ScopeEndpointRelation,
                },
                {
                        name: "only serviceName is not empty",
-                       args: &schema.Entity{
+                       args: &api.Entity{
                                ServiceName:             &nonEmpty,
                                ServiceInstanceName:     &empty,
                                EndpointName:            &empty,
@@ -65,11 +65,11 @@ func Test_parseScope(t *testing.T) {
                                DestServiceInstanceName: &empty,
                                DestEndpointName:        &empty,
                        },
-                       want: schema.ScopeService,
+                       want: api.ScopeService,
                },
                {
                        name: "instanceName is not empty",
-                       args: &schema.Entity{
+                       args: &api.Entity{
                                ServiceName:             &nonEmpty,
                                ServiceInstanceName:     &nonEmpty,
                                EndpointName:            &empty,
@@ -77,11 +77,11 @@ func Test_parseScope(t *testing.T) {
                                DestServiceInstanceName: &empty,
                                DestEndpointName:        &empty,
                        },
-                       want: schema.ScopeServiceInstance,
+                       want: api.ScopeServiceInstance,
                },
                {
                        name: "endpointName is not empty",
-                       args: &schema.Entity{
+                       args: &api.Entity{
                                ServiceName:             &nonEmpty,
                                ServiceInstanceName:     &empty,
                                EndpointName:            &nonEmpty,
@@ -89,11 +89,11 @@ func Test_parseScope(t *testing.T) {
                                DestServiceInstanceName: &empty,
                                DestEndpointName:        &empty,
                        },
-                       want: schema.ScopeEndpoint,
+                       want: api.ScopeEndpoint,
                },
                {
                        name: "destService is not empty",
-                       args: &schema.Entity{
+                       args: &api.Entity{
                                ServiceName:             &nonEmpty,
                                ServiceInstanceName:     &empty,
                                EndpointName:            &empty,
@@ -101,11 +101,11 @@ func Test_parseScope(t *testing.T) {
                                DestServiceInstanceName: &empty,
                                DestEndpointName:        &empty,
                        },
-                       want: schema.ScopeServiceRelation,
+                       want: api.ScopeServiceRelation,
                },
                {
                        name: "destInstance is not empty",
-                       args: &schema.Entity{
+                       args: &api.Entity{
                                ServiceName:             &nonEmpty,
                                ServiceInstanceName:     &nonEmpty,
                                EndpointName:            &empty,
@@ -113,7 +113,7 @@ func Test_parseScope(t *testing.T) {
                                DestServiceInstanceName: &nonEmpty,
                                DestEndpointName:        &empty,
                        },
-                       want: schema.ScopeServiceInstanceRelation,
+                       want: api.ScopeServiceInstanceRelation,
                },
        }
        for _, tt := range tests {
diff --git a/commands/interceptor/interceptor.go 
b/internal/commands/interceptor/interceptor.go
similarity index 100%
rename from commands/interceptor/interceptor.go
rename to internal/commands/interceptor/interceptor.go
diff --git a/commands/interceptor/timezone.go 
b/internal/commands/interceptor/timezone.go
similarity index 93%
rename from commands/interceptor/timezone.go
rename to internal/commands/interceptor/timezone.go
index c724276..f75c318 100644
--- a/commands/interceptor/timezone.go
+++ b/internal/commands/interceptor/timezone.go
@@ -22,8 +22,8 @@ import (
 
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/graphql/metadata"
-       "github.com/apache/skywalking-cli/logger"
+       "github.com/apache/skywalking-cli/internal/logger"
+       "github.com/apache/skywalking-cli/pkg/graphql/metadata"
 )
 
 // TimezoneInterceptor sets the server timezone if the server supports the API,
diff --git a/commands/metrics/aggregation/topn.go 
b/internal/commands/metrics/aggregation/topn.go
similarity index 77%
rename from commands/metrics/aggregation/topn.go
rename to internal/commands/metrics/aggregation/topn.go
index a3505cf..519d2dc 100644
--- a/commands/metrics/aggregation/topn.go
+++ b/internal/commands/metrics/aggregation/topn.go
@@ -21,15 +21,17 @@ import (
        "fmt"
        "strconv"
 
-       "github.com/apache/skywalking-cli/commands/flags"
-       "github.com/apache/skywalking-cli/commands/interceptor"
-       "github.com/apache/skywalking-cli/commands/model"
-       "github.com/apache/skywalking-cli/display"
-       "github.com/apache/skywalking-cli/display/displayable"
-       "github.com/apache/skywalking-cli/graphql/metrics"
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/api"
+       "github.com/apache/skywalking-cli/internal/logger"
 
        "github.com/urfave/cli"
+
+       "github.com/apache/skywalking-cli/internal/commands/interceptor"
+       "github.com/apache/skywalking-cli/internal/flags"
+       "github.com/apache/skywalking-cli/internal/model"
+       "github.com/apache/skywalking-cli/pkg/display"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
+       "github.com/apache/skywalking-cli/pkg/graphql/metrics"
 )
 
 var TopN = cli.Command{
@@ -44,9 +46,9 @@ var TopN = cli.Command{
                                Name:  "order",
                                Usage: "the `order` by which the top entities 
are sorted",
                                Value: &model.OrderEnumValue{
-                                       Enum:     schema.AllOrder,
-                                       Default:  schema.OrderDes,
-                                       Selected: schema.OrderDes,
+                                       Enum:     api.AllOrder,
+                                       Default:  api.OrderDes,
+                                       Selected: api.OrderDes,
                                },
                        },
                },
@@ -75,13 +77,13 @@ var TopN = cli.Command{
                        topN = nn
                }
 
-               duration := schema.Duration{
+               duration := api.Duration{
                        Start: start,
                        End:   end,
                        Step:  step,
                }
 
-               metricsValues := metrics.SortMetrics(ctx, schema.TopNCondition{
+               metricsValues, err := metrics.SortMetrics(ctx, 
api.TopNCondition{
                        Name:          metricsName,
                        ParentService: &parentService,
                        Normal:        &normal,
@@ -90,6 +92,10 @@ var TopN = cli.Command{
                        Order:         order,
                }, duration)
 
+               if err != nil {
+                       logger.Log.Fatalln(err)
+               }
+
                return display.Display(ctx, &displayable.Displayable{Data: 
metricsValues})
        },
 }
diff --git a/commands/metrics/linear/linear-metrics.go 
b/internal/commands/metrics/linear/linear-metrics.go
similarity index 72%
rename from commands/metrics/linear/linear-metrics.go
rename to internal/commands/metrics/linear/linear-metrics.go
index 717943c..e48ca36 100644
--- a/commands/metrics/linear/linear-metrics.go
+++ b/internal/commands/metrics/linear/linear-metrics.go
@@ -18,14 +18,15 @@
 package linear
 
 import (
-       "github.com/apache/skywalking-cli/commands/flags"
-       "github.com/apache/skywalking-cli/commands/interceptor"
-       "github.com/apache/skywalking-cli/commands/model"
-       "github.com/apache/skywalking-cli/display"
-       "github.com/apache/skywalking-cli/display/displayable"
-       "github.com/apache/skywalking-cli/graphql/metrics"
-       "github.com/apache/skywalking-cli/graphql/schema"
-       "github.com/apache/skywalking-cli/graphql/utils"
+       "github.com/apache/skywalking-cli/api"
+       "github.com/apache/skywalking-cli/internal/commands/interceptor"
+       "github.com/apache/skywalking-cli/internal/flags"
+       "github.com/apache/skywalking-cli/internal/logger"
+       "github.com/apache/skywalking-cli/internal/model"
+       "github.com/apache/skywalking-cli/pkg/display"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
+       "github.com/apache/skywalking-cli/pkg/graphql/metrics"
+       "github.com/apache/skywalking-cli/pkg/graphql/utils"
 
        "github.com/urfave/cli"
 )
@@ -50,17 +51,21 @@ var Single = cli.Command{
                metricsName := ctx.String("name")
                entity := interceptor.ParseEntity(ctx)
 
-               duration := schema.Duration{
+               duration := api.Duration{
                        Start: start,
                        End:   end,
                        Step:  step.(*model.StepEnumValue).Selected,
                }
 
-               metricsValues := metrics.LinearIntValues(ctx, 
schema.MetricsCondition{
+               metricsValues, err := metrics.LinearIntValues(ctx, 
api.MetricsCondition{
                        Name:   metricsName,
                        Entity: entity,
                }, duration)
 
+               if err != nil {
+                       logger.Log.Fatalln(err)
+               }
+
                return display.Display(ctx, &displayable.Displayable{Data: 
utils.MetricsValuesToMap(duration, metricsValues)})
        },
 }
diff --git a/commands/metrics/linear/multiple-linear-metrics.go 
b/internal/commands/metrics/linear/multiple-linear-metrics.go
similarity index 74%
rename from commands/metrics/linear/multiple-linear-metrics.go
rename to internal/commands/metrics/linear/multiple-linear-metrics.go
index d5165cf..6a1e2fb 100644
--- a/commands/metrics/linear/multiple-linear-metrics.go
+++ b/internal/commands/metrics/linear/multiple-linear-metrics.go
@@ -21,14 +21,16 @@ import (
        "fmt"
        "strings"
 
-       "github.com/apache/skywalking-cli/commands/flags"
-       "github.com/apache/skywalking-cli/commands/interceptor"
-       "github.com/apache/skywalking-cli/commands/model"
-       "github.com/apache/skywalking-cli/display"
-       "github.com/apache/skywalking-cli/display/displayable"
-       "github.com/apache/skywalking-cli/graphql/metrics"
-       "github.com/apache/skywalking-cli/graphql/schema"
-       "github.com/apache/skywalking-cli/graphql/utils"
+       "github.com/apache/skywalking-cli/api"
+       "github.com/apache/skywalking-cli/internal/logger"
+
+       "github.com/apache/skywalking-cli/internal/commands/interceptor"
+       "github.com/apache/skywalking-cli/internal/flags"
+       "github.com/apache/skywalking-cli/internal/model"
+       "github.com/apache/skywalking-cli/pkg/display"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
+       "github.com/apache/skywalking-cli/pkg/graphql/metrics"
+       "github.com/apache/skywalking-cli/pkg/graphql/utils"
 
        "github.com/urfave/cli"
 )
@@ -62,21 +64,25 @@ var Multiple = cli.Command{
                labels := ctx.String("labels")
                entity := interceptor.ParseEntity(ctx)
 
-               if *entity.ServiceName == "" && entity.Scope != schema.ScopeAll 
{
+               if *entity.ServiceName == "" && entity.Scope != api.ScopeAll {
                        return fmt.Errorf("the name of service should be 
specified when metrics' scope is not `All`")
                }
 
-               duration := schema.Duration{
+               duration := api.Duration{
                        Start: start,
                        End:   end,
                        Step:  step.(*model.StepEnumValue).Selected,
                }
 
-               metricsValuesArray := metrics.MultipleLinearIntValues(ctx, 
schema.MetricsCondition{
+               metricsValuesArray, err := metrics.MultipleLinearIntValues(ctx, 
api.MetricsCondition{
                        Name:   metricsName,
                        Entity: interceptor.ParseEntity(ctx),
                }, strings.Split(labels, ","), duration)
 
+               if err != nil {
+                       logger.Log.Fatalln(err)
+               }
+
                reshaped := utils.MetricsValuesArrayToMap(duration, 
metricsValuesArray)
                return display.Display(ctx, &displayable.Displayable{Data: 
reshaped})
        },
diff --git a/commands/metrics/list/list-metrics.go 
b/internal/commands/metrics/list/list-metrics.go
similarity index 79%
rename from commands/metrics/list/list-metrics.go
rename to internal/commands/metrics/list/list-metrics.go
index 8b22349..ca67689 100644
--- a/commands/metrics/list/list-metrics.go
+++ b/internal/commands/metrics/list/list-metrics.go
@@ -20,9 +20,11 @@ package list
 import (
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/display"
-       "github.com/apache/skywalking-cli/display/displayable"
-       "github.com/apache/skywalking-cli/graphql/metrics"
+       "github.com/apache/skywalking-cli/internal/logger"
+
+       "github.com/apache/skywalking-cli/pkg/display"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
+       "github.com/apache/skywalking-cli/pkg/graphql/metrics"
 )
 
 var Command = cli.Command{
@@ -38,7 +40,11 @@ var Command = cli.Command{
        Action: func(ctx *cli.Context) error {
                regex := ctx.String("regex")
 
-               metricsValue := metrics.ListMetrics(ctx, regex)
+               metricsValue, err := metrics.ListMetrics(ctx, regex)
+
+               if err != nil {
+                       logger.Log.Fatalln(err)
+               }
 
                return display.Display(ctx, &displayable.Displayable{Data: 
metricsValue})
        },
diff --git a/commands/metrics/metrics.go b/internal/commands/metrics/metrics.go
similarity index 75%
rename from commands/metrics/metrics.go
rename to internal/commands/metrics/metrics.go
index 9ba471b..78196d7 100644
--- a/commands/metrics/metrics.go
+++ b/internal/commands/metrics/metrics.go
@@ -20,13 +20,13 @@ package metrics
 import (
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/commands/metrics/aggregation"
-       "github.com/apache/skywalking-cli/commands/metrics/list"
+       "github.com/apache/skywalking-cli/internal/commands/metrics/aggregation"
+       "github.com/apache/skywalking-cli/internal/commands/metrics/list"
 
-       "github.com/apache/skywalking-cli/commands/metrics/thermodynamic"
+       
"github.com/apache/skywalking-cli/internal/commands/metrics/thermodynamic"
 
-       "github.com/apache/skywalking-cli/commands/metrics/linear"
-       "github.com/apache/skywalking-cli/commands/metrics/single"
+       "github.com/apache/skywalking-cli/internal/commands/metrics/linear"
+       "github.com/apache/skywalking-cli/internal/commands/metrics/single"
 )
 
 var Command = cli.Command{
diff --git a/commands/metrics/single/single-metrics.go 
b/internal/commands/metrics/single/single-metrics.go
similarity index 74%
rename from commands/metrics/single/single-metrics.go
rename to internal/commands/metrics/single/single-metrics.go
index 05469ec..d4ff085 100644
--- a/commands/metrics/single/single-metrics.go
+++ b/internal/commands/metrics/single/single-metrics.go
@@ -18,15 +18,16 @@
 package single
 
 import (
-       "github.com/apache/skywalking-cli/commands/flags"
-       "github.com/apache/skywalking-cli/commands/interceptor"
-       "github.com/apache/skywalking-cli/commands/model"
-       "github.com/apache/skywalking-cli/display"
-       "github.com/apache/skywalking-cli/display/displayable"
-       "github.com/apache/skywalking-cli/graphql/metrics"
-       "github.com/apache/skywalking-cli/graphql/schema"
-
        "github.com/urfave/cli"
+
+       "github.com/apache/skywalking-cli/api"
+       "github.com/apache/skywalking-cli/internal/commands/interceptor"
+       "github.com/apache/skywalking-cli/internal/flags"
+       "github.com/apache/skywalking-cli/internal/logger"
+       "github.com/apache/skywalking-cli/internal/model"
+       "github.com/apache/skywalking-cli/pkg/display"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
+       "github.com/apache/skywalking-cli/pkg/graphql/metrics"
 )
 
 var Command = cli.Command{
@@ -49,17 +50,21 @@ var Command = cli.Command{
                metricsName := ctx.String("name")
                entity := interceptor.ParseEntity(ctx)
 
-               duration := schema.Duration{
+               duration := api.Duration{
                        Start: start,
                        End:   end,
                        Step:  step.(*model.StepEnumValue).Selected,
                }
 
-               metricsValue := metrics.IntValues(ctx, schema.MetricsCondition{
+               metricsValue, err := metrics.IntValues(ctx, 
api.MetricsCondition{
                        Name:   metricsName,
                        Entity: entity,
                }, duration)
 
+               if err != nil {
+                       logger.Log.Fatalln(err)
+               }
+
                return display.Display(ctx, &displayable.Displayable{Data: 
metricsValue})
        },
 }
diff --git a/commands/metrics/thermodynamic/thermodynamic.go 
b/internal/commands/metrics/thermodynamic/thermodynamic.go
similarity index 75%
rename from commands/metrics/thermodynamic/thermodynamic.go
rename to internal/commands/metrics/thermodynamic/thermodynamic.go
index 63d3f94..ccc2cd7 100644
--- a/commands/metrics/thermodynamic/thermodynamic.go
+++ b/internal/commands/metrics/thermodynamic/thermodynamic.go
@@ -18,15 +18,16 @@
 package thermodynamic
 
 import (
-       "github.com/apache/skywalking-cli/commands/flags"
-       "github.com/apache/skywalking-cli/commands/interceptor"
-       "github.com/apache/skywalking-cli/commands/model"
-       "github.com/apache/skywalking-cli/display"
-       "github.com/apache/skywalking-cli/display/displayable"
-       "github.com/apache/skywalking-cli/graphql/metrics"
-       "github.com/apache/skywalking-cli/graphql/schema"
-
        "github.com/urfave/cli"
+
+       "github.com/apache/skywalking-cli/api"
+       "github.com/apache/skywalking-cli/internal/commands/interceptor"
+       "github.com/apache/skywalking-cli/internal/flags"
+       "github.com/apache/skywalking-cli/internal/logger"
+       "github.com/apache/skywalking-cli/internal/model"
+       "github.com/apache/skywalking-cli/pkg/display"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
+       "github.com/apache/skywalking-cli/pkg/graphql/metrics"
 )
 
 var Command = cli.Command{
@@ -50,17 +51,21 @@ var Command = cli.Command{
                metricsName := ctx.String("name")
                entity := interceptor.ParseEntity(ctx)
 
-               duration := schema.Duration{
+               duration := api.Duration{
                        Start: start,
                        End:   end,
                        Step:  step.(*model.StepEnumValue).Selected,
                }
 
-               metricsValues := metrics.Thermodynamic(ctx, 
schema.MetricsCondition{
+               metricsValues, err := metrics.Thermodynamic(ctx, 
api.MetricsCondition{
                        Name:   metricsName,
                        Entity: entity,
                }, duration)
 
+               if err != nil {
+                       logger.Log.Fatalln(err)
+               }
+
                return display.Display(ctx, &displayable.Displayable{
                        Data:     metricsValues,
                        Duration: duration,
diff --git a/commands/service/list.go b/internal/commands/service/list.go
similarity index 69%
rename from commands/service/list.go
rename to internal/commands/service/list.go
index 14e2830..3776ab7 100644
--- a/commands/service/list.go
+++ b/internal/commands/service/list.go
@@ -20,15 +20,17 @@ package service
 import (
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/display/displayable"
+       "github.com/apache/skywalking-cli/api"
+       "github.com/apache/skywalking-cli/internal/logger"
 
-       "github.com/apache/skywalking-cli/graphql/metadata"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
 
-       "github.com/apache/skywalking-cli/commands/flags"
-       "github.com/apache/skywalking-cli/commands/interceptor"
-       "github.com/apache/skywalking-cli/commands/model"
-       "github.com/apache/skywalking-cli/display"
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/pkg/graphql/metadata"
+
+       "github.com/apache/skywalking-cli/internal/commands/interceptor"
+       "github.com/apache/skywalking-cli/internal/flags"
+       "github.com/apache/skywalking-cli/internal/model"
+       "github.com/apache/skywalking-cli/pkg/display"
 )
 
 var ListCommand = cli.Command{
@@ -47,17 +49,24 @@ var ListCommand = cli.Command{
                start := ctx.String("start")
                step := ctx.Generic("step")
 
-               var services []schema.Service
+               var services []api.Service
+               var err error
 
                if args := ctx.Args(); len(args) == 0 {
-                       services = metadata.AllServices(ctx, schema.Duration{
+                       services, err = metadata.AllServices(ctx, api.Duration{
                                Start: start,
                                End:   end,
                                Step:  step.(*model.StepEnumValue).Selected,
                        })
+                       if err != nil {
+                               logger.Log.Fatalln(err)
+                       }
                } else {
-                       service, _ := metadata.SearchService(ctx, args.First())
-                       services = []schema.Service{service}
+                       service, err := metadata.SearchService(ctx, 
args.First())
+                       if err != nil {
+                               logger.Log.Fatalln(err)
+                       }
+                       services = []api.Service{service}
                }
 
                return display.Display(ctx, &displayable.Displayable{Data: 
services})
diff --git a/commands/service/service.go b/internal/commands/service/service.go
similarity index 100%
rename from commands/service/service.go
rename to internal/commands/service/service.go
diff --git a/commands/trace/list.go b/internal/commands/trace/list.go
similarity index 76%
rename from commands/trace/list.go
rename to internal/commands/trace/list.go
index 0d875c7..067d745 100644
--- a/commands/trace/list.go
+++ b/internal/commands/trace/list.go
@@ -20,18 +20,20 @@ package trace
 import (
        "strings"
 
-       "github.com/apache/skywalking-cli/display/displayable"
+       "github.com/apache/skywalking-cli/api"
+       "github.com/apache/skywalking-cli/internal/logger"
 
-       "github.com/apache/skywalking-cli/commands/interceptor"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
+
+       "github.com/apache/skywalking-cli/internal/commands/interceptor"
 
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/commands/flags"
-       "github.com/apache/skywalking-cli/commands/model"
-       "github.com/apache/skywalking-cli/display"
+       "github.com/apache/skywalking-cli/internal/flags"
+       "github.com/apache/skywalking-cli/internal/model"
+       "github.com/apache/skywalking-cli/pkg/display"
 
-       "github.com/apache/skywalking-cli/graphql/schema"
-       "github.com/apache/skywalking-cli/graphql/trace"
+       "github.com/apache/skywalking-cli/pkg/graphql/trace"
 )
 
 const DefaultPageSize = 15
@@ -75,7 +77,7 @@ var ListCommand = cli.Command{
                end := ctx.String("end")
                step := ctx.Generic("step")
 
-               duration := schema.Duration{
+               duration := api.Duration{
                        Start: start,
                        End:   end,
                        Step:  step.(*model.StepEnumValue).Selected,
@@ -84,24 +86,24 @@ var ListCommand = cli.Command{
                serviceInstanceID := ctx.String("service-instance-id")
                traceID := ctx.String("trace-id")
                tagStr := ctx.String("tags")
-               var tags []*schema.SpanTag = nil
+               var tags []*api.SpanTag = nil
                if tagStr != "" {
                        tagArr := strings.Split(tagStr, ",")
                        for _, tag := range tagArr {
                                kv := strings.Split(tag, "=")
-                               tags = append(tags, &schema.SpanTag{Key: kv[0], 
Value: &kv[1]})
+                               tags = append(tags, &api.SpanTag{Key: kv[0], 
Value: &kv[1]})
                        }
                }
                pageNum := 1
                needTotal := true
 
-               paging := schema.Pagination{
+               paging := api.Pagination{
                        PageNum:   &pageNum,
                        PageSize:  DefaultPageSize,
                        NeedTotal: &needTotal,
                }
 
-               condition := &schema.TraceQueryCondition{
+               condition := &api.TraceQueryCondition{
                        ServiceID:         &serviceID,
                        ServiceInstanceID: &serviceInstanceID,
                        TraceID:           &traceID,
@@ -110,12 +112,16 @@ var ListCommand = cli.Command{
                        QueryDuration:     &duration,
                        MinTraceDuration:  nil,
                        MaxTraceDuration:  nil,
-                       TraceState:        schema.TraceStateAll,
-                       QueryOrder:        schema.QueryOrderByDuration,
+                       TraceState:        api.TraceStateAll,
+                       QueryOrder:        api.QueryOrderByDuration,
                        Tags:              tags,
                        Paging:            &paging,
                }
-               traces := trace.Traces(ctx, condition)
+               traces, err := trace.Traces(ctx, condition)
+
+               if err != nil {
+                       logger.Log.Fatalln(err)
+               }
 
                return display.Display(ctx, &displayable.Displayable{Data: 
traces, Condition: condition})
        },
diff --git a/commands/trace/trace.go b/internal/commands/trace/trace.go
similarity index 80%
rename from commands/trace/trace.go
rename to internal/commands/trace/trace.go
index a6dd408..9def645 100644
--- a/commands/trace/trace.go
+++ b/internal/commands/trace/trace.go
@@ -20,11 +20,13 @@ package trace
 import (
        "fmt"
 
+       "github.com/apache/skywalking-cli/internal/logger"
+
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/display"
-       "github.com/apache/skywalking-cli/display/displayable"
-       "github.com/apache/skywalking-cli/graphql/trace"
+       "github.com/apache/skywalking-cli/pkg/display"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
+       "github.com/apache/skywalking-cli/pkg/graphql/trace"
 )
 
 var Command = cli.Command{
@@ -37,7 +39,11 @@ var Command = cli.Command{
                        return fmt.Errorf("command trace without sub command 
requires 1 trace id as argument")
                }
 
-               trace := trace.Trace(ctx, ctx.Args().First())
+               trace, err := trace.Trace(ctx, ctx.Args().First())
+
+               if err != nil {
+                       logger.Log.Fatalln(err)
+               }
 
                return display.Display(ctx, &displayable.Displayable{Data: 
trace})
        },
diff --git a/commands/flags/duration.go b/internal/flags/duration.go
similarity index 83%
rename from commands/flags/duration.go
rename to internal/flags/duration.go
index 152ba0e..00d9ce8 100644
--- a/commands/flags/duration.go
+++ b/internal/flags/duration.go
@@ -20,11 +20,12 @@ package flags
 import (
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/commands/model"
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/api"
+
+       "github.com/apache/skywalking-cli/internal/model"
 )
 
-// DurationFlags are common flags that involves a duration, composed
+// DurationFlags are healthcheck flags that involves a duration, composed
 // by a start time, an end time, and a step, which is commonly used
 // in most of the commands
 var DurationFlags = []cli.Flag{
@@ -40,9 +41,9 @@ var DurationFlags = []cli.Flag{
                Name:   "step",
                Hidden: true,
                Value: &model.StepEnumValue{
-                       Enum:     schema.AllStep,
-                       Default:  schema.StepMinute,
-                       Selected: schema.StepMinute,
+                       Enum:     api.AllStep,
+                       Default:  api.StepMinute,
+                       Selected: api.StepMinute,
                },
        },
        cli.StringFlag{
diff --git a/commands/flags/entity.go b/internal/flags/entity.go
similarity index 100%
rename from commands/flags/entity.go
rename to internal/flags/entity.go
diff --git a/commands/flags/flags.go b/internal/flags/flags.go
similarity index 100%
rename from commands/flags/flags.go
rename to internal/flags/flags.go
diff --git a/commands/flags/instance.go b/internal/flags/instance.go
similarity index 100%
rename from commands/flags/instance.go
rename to internal/flags/instance.go
diff --git a/commands/flags/metrics.go b/internal/flags/metrics.go
similarity index 87%
rename from commands/flags/metrics.go
rename to internal/flags/metrics.go
index cda10a3..51ece74 100644
--- a/commands/flags/metrics.go
+++ b/internal/flags/metrics.go
@@ -18,10 +18,10 @@
 package flags
 
 import (
-       "github.com/apache/skywalking-cli/commands/model"
-       "github.com/apache/skywalking-cli/graphql/schema"
-
        "github.com/urfave/cli"
+
+       "github.com/apache/skywalking-cli/api"
+       "github.com/apache/skywalking-cli/internal/model"
 )
 
 // MetricsFlags can be reused in metrics commands.
@@ -46,9 +46,9 @@ var MetricsFlags = []cli.Flag{
                Name:  "scope",
                Usage: "the scope of the metrics entity",
                Value: &model.ScopeEnumValue{
-                       Enum:     schema.AllScope,
-                       Default:  schema.ScopeService,
-                       Selected: schema.ScopeService,
+                       Enum:     api.AllScope,
+                       Default:  api.ScopeService,
+                       Selected: api.ScopeService,
                },
        },
 }
diff --git a/commands/flags/search.go b/internal/flags/search.go
similarity index 100%
rename from commands/flags/search.go
rename to internal/flags/search.go
diff --git a/logger/log.go b/internal/logger/log.go
similarity index 100%
rename from logger/log.go
rename to internal/logger/log.go
diff --git a/commands/model/order.go b/internal/model/order.go
similarity index 86%
rename from commands/model/order.go
rename to internal/model/order.go
index 77a20ba..83bfb12 100644
--- a/commands/model/order.go
+++ b/internal/model/order.go
@@ -21,14 +21,14 @@ import (
        "fmt"
        "strings"
 
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/api"
 )
 
 // OrderEnumValue defines the values domain of --order option
 type OrderEnumValue struct {
-       Enum     []schema.Order
-       Default  schema.Order
-       Selected schema.Order
+       Enum     []api.Order
+       Default  api.Order
+       Selected api.Order
 }
 
 // Set the --order value, from raw string to OrderEnumValue
@@ -39,8 +39,8 @@ func (s *OrderEnumValue) Set(value string) error {
                        return nil
                }
        }
-       orders := make([]string, len(schema.AllOrder))
-       for i, order := range schema.AllOrder {
+       orders := make([]string, len(api.AllOrder))
+       for i, order := range api.AllOrder {
                orders[i] = order.String()
        }
        return fmt.Errorf("allowed orders are %s", strings.Join(orders, ", "))
diff --git a/commands/model/scope.go b/internal/model/scope.go
similarity index 86%
rename from commands/model/scope.go
rename to internal/model/scope.go
index 7adc5e2..1175cb2 100644
--- a/commands/model/scope.go
+++ b/internal/model/scope.go
@@ -21,14 +21,14 @@ import (
        "fmt"
        "strings"
 
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/api"
 )
 
 // ScopeEnumValue defines the values domain of --scope option
 type ScopeEnumValue struct {
-       Enum     []schema.Scope
-       Default  schema.Scope
-       Selected schema.Scope
+       Enum     []api.Scope
+       Default  api.Scope
+       Selected api.Scope
 }
 
 // Set the --scope value, from raw string to ScopeEnumValue
@@ -39,8 +39,8 @@ func (s *ScopeEnumValue) Set(value string) error {
                        return nil
                }
        }
-       scopes := make([]string, len(schema.AllScope))
-       for i, scope := range schema.AllScope {
+       scopes := make([]string, len(api.AllScope))
+       for i, scope := range api.AllScope {
                scopes[i] = scope.String()
        }
        return fmt.Errorf("allowed scopes are %s", strings.Join(scopes, ", "))
diff --git a/commands/model/step.go b/internal/model/step.go
similarity index 87%
rename from commands/model/step.go
rename to internal/model/step.go
index 8f363be..eeef268 100644
--- a/commands/model/step.go
+++ b/internal/model/step.go
@@ -21,14 +21,14 @@ import (
        "fmt"
        "strings"
 
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/api"
 )
 
 // StepEnumValue defines the values domain of --step option
 type StepEnumValue struct {
-       Enum     []schema.Step
-       Default  schema.Step
-       Selected schema.Step
+       Enum     []api.Step
+       Default  api.Step
+       Selected api.Step
 }
 
 // Set the --step value, from raw string to StepEnumValue
@@ -39,8 +39,8 @@ func (s *StepEnumValue) Set(value string) error {
                        return nil
                }
        }
-       steps := make([]string, len(schema.AllStep))
-       for i, step := range schema.AllStep {
+       steps := make([]string, len(api.AllStep))
+       for i, step := range api.AllStep {
                steps[i] = step.String()
        }
        return fmt.Errorf("allowed steps are %s", strings.Join(steps, ", "))
diff --git a/display/display.go b/pkg/display/display.go
similarity index 84%
rename from display/display.go
rename to pkg/display/display.go
index 9e7d132..9dd17b8 100644
--- a/display/display.go
+++ b/pkg/display/display.go
@@ -21,15 +21,15 @@ import (
        "fmt"
        "strings"
 
-       d "github.com/apache/skywalking-cli/display/displayable"
+       d "github.com/apache/skywalking-cli/pkg/display/displayable"
 
-       "github.com/apache/skywalking-cli/display/graph"
+       "github.com/apache/skywalking-cli/pkg/display/graph"
 
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/display/json"
-       "github.com/apache/skywalking-cli/display/table"
-       "github.com/apache/skywalking-cli/display/yaml"
+       "github.com/apache/skywalking-cli/pkg/display/json"
+       "github.com/apache/skywalking-cli/pkg/display/table"
+       "github.com/apache/skywalking-cli/pkg/display/yaml"
 )
 
 const (
diff --git a/display/displayable/displayable.go 
b/pkg/display/displayable/displayable.go
similarity index 91%
rename from display/displayable/displayable.go
rename to pkg/display/displayable/displayable.go
index d4678f4..eff05d0 100644
--- a/display/displayable/displayable.go
+++ b/pkg/display/displayable/displayable.go
@@ -17,11 +17,13 @@
 
 package displayable
 
-import "github.com/apache/skywalking-cli/graphql/schema"
+import (
+       "github.com/apache/skywalking-cli/api"
+)
 
 type Displayable struct {
        Data      interface{}
        Condition interface{}
-       Duration  schema.Duration
+       Duration  api.Duration
        Title     string
 }
diff --git a/display/graph/dashboard/global.go 
b/pkg/display/graph/dashboard/global.go
similarity index 91%
rename from display/graph/dashboard/global.go
rename to pkg/display/graph/dashboard/global.go
index 0865a2e..084952e 100644
--- a/display/graph/dashboard/global.go
+++ b/pkg/display/graph/dashboard/global.go
@@ -24,10 +24,11 @@ import (
        "strings"
        "time"
 
-       "github.com/apache/skywalking-cli/commands/interceptor"
-       "github.com/apache/skywalking-cli/graphql/schema"
-       "github.com/apache/skywalking-cli/graphql/utils"
-       lib "github.com/apache/skywalking-cli/lib/heatmap"
+       "github.com/apache/skywalking-cli/api"
+
+       "github.com/apache/skywalking-cli/internal/commands/interceptor"
+       "github.com/apache/skywalking-cli/pkg/graphql/utils"
+       lib "github.com/apache/skywalking-cli/pkg/heatmap"
 
        "github.com/mattn/go-runewidth"
        "github.com/mum4k/termdash"
@@ -37,10 +38,10 @@ import (
        "github.com/mum4k/termdash/terminal/terminalapi"
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/display/graph/gauge"
-       "github.com/apache/skywalking-cli/display/graph/heatmap"
-       "github.com/apache/skywalking-cli/display/graph/linear"
-       "github.com/apache/skywalking-cli/graphql/dashboard"
+       "github.com/apache/skywalking-cli/pkg/display/graph/gauge"
+       "github.com/apache/skywalking-cli/pkg/display/graph/heatmap"
+       "github.com/apache/skywalking-cli/pkg/display/graph/linear"
+       "github.com/apache/skywalking-cli/pkg/graphql/dashboard"
 
        "github.com/mum4k/termdash/cell"
        "github.com/mum4k/termdash/container"
@@ -202,8 +203,8 @@ func newWidgets(data *dashboard.GlobalData) error {
        var linears []*linechart.LineChart
 
        // Create gauges to display global metrics.
-       for i, t := range template.Metrics {
-               col, err := gauge.NewMetricColumn(data.Metrics[i], &t)
+       for i := range template.Metrics {
+               col, err := gauge.NewMetricColumn(data.Metrics[i], 
&template.Metrics[i])
                if err != nil {
                        return err
                }
@@ -340,7 +341,11 @@ func refresh(con context.Context, ctx *cli.Context, 
interval time.Duration) {
                                continue
                        }
 
-                       data := dashboard.Global(ctx, d)
+                       data, err := dashboard.Global(ctx, d)
+                       if err != nil {
+                               continue
+                       }
+
                        if err := updateAllWidgets(data); err != nil {
                                continue
                        }
@@ -353,10 +358,10 @@ func refresh(con context.Context, ctx *cli.Context, 
interval time.Duration) {
 // updateDuration will check if the duration changes after adding the interval.
 // If the duration doesn't change, an error will be returned, and the 
dashboard will not refresh.
 // Otherwise, a new duration will be returned, which is used to get the latest 
global data.
-func updateDuration(interval time.Duration) (schema.Duration, error) {
+func updateDuration(interval time.Duration) (api.Duration, error) {
        step, _, err := interceptor.TryParseTime(initStartStr)
        if err != nil {
-               return schema.Duration{}, err
+               return api.Duration{}, err
        }
 
        curStartTime = curStartTime.Add(interval)
@@ -366,12 +371,12 @@ func updateDuration(interval time.Duration) 
(schema.Duration, error) {
        curEndStr := curEndTime.Format(utils.StepFormats[step])
 
        if curStartStr == initStartStr && curEndStr == initEndStr {
-               return schema.Duration{}, fmt.Errorf("the duration does not 
update")
+               return api.Duration{}, fmt.Errorf("the duration does not 
update")
        }
 
        initStartStr = curStartStr
        initEndStr = curEndStr
-       return schema.Duration{
+       return api.Duration{
                Start: curStartStr,
                End:   curEndStr,
                Step:  step,
diff --git a/display/graph/gauge/gauge.go b/pkg/display/graph/gauge/gauge.go
similarity index 91%
rename from display/graph/gauge/gauge.go
rename to pkg/display/graph/gauge/gauge.go
index a99234d..14ab4ae 100644
--- a/display/graph/gauge/gauge.go
+++ b/pkg/display/graph/gauge/gauge.go
@@ -24,11 +24,12 @@ import (
        "strconv"
        "strings"
 
+       "github.com/apache/skywalking-cli/api"
+
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/graphql/dashboard"
-       "github.com/apache/skywalking-cli/graphql/schema"
-       "github.com/apache/skywalking-cli/util"
+       "github.com/apache/skywalking-cli/pkg/graphql/dashboard"
+       "github.com/apache/skywalking-cli/pkg/util"
 
        "github.com/mum4k/termdash"
        "github.com/mum4k/termdash/cell"
@@ -50,7 +51,7 @@ type MetricColumn struct {
 }
 
 // Update updates the MetricColumn's `Absolute` and `BorderTitle`.
-func (mc *MetricColumn) Update(data []*schema.SelectedRecord) error {
+func (mc *MetricColumn) Update(data []*api.SelectedRecord) error {
        for i, item := range data {
                // The number of `SelectedRecord` data may exceed the number of 
gauges in a `MetricColumn`.
                if i >= len(mc.gauges) {
@@ -79,7 +80,7 @@ func (mc *MetricColumn) Update(data []*schema.SelectedRecord) 
error {
        return nil
 }
 
-func NewMetricColumn(column []*schema.SelectedRecord, config 
*dashboard.MetricTemplate) (*MetricColumn, error) {
+func NewMetricColumn(column []*api.SelectedRecord, config 
*dashboard.MetricTemplate) (*MetricColumn, error) {
        var ret MetricColumn
 
        t, err := text.New()
@@ -193,7 +194,7 @@ func layout(columns []grid.Element) ([]container.Option, 
error) {
        return gridOpts, nil
 }
 
-func Display(ctx *cli.Context, metrics [][]*schema.SelectedRecord) error {
+func Display(ctx *cli.Context, metrics [][]*api.SelectedRecord) error {
        t, err := termbox.New()
        if err != nil {
                return err
@@ -215,8 +216,8 @@ func Display(ctx *cli.Context, metrics 
[][]*schema.SelectedRecord) error {
                return nil
        }
 
-       for i, config := range configs.Metrics {
-               col, innerErr := NewMetricColumn(metrics[i], &config)
+       for i := range configs.Metrics {
+               col, innerErr := NewMetricColumn(metrics[i], 
&configs.Metrics[i])
                if innerErr != nil {
                        return innerErr
                }
@@ -251,7 +252,7 @@ func Display(ctx *cli.Context, metrics 
[][]*schema.SelectedRecord) error {
 }
 
 // findMaxValue finds the maximum value in the array of 
`schema.SelectedRecord`.
-func findMaxValue(column []*schema.SelectedRecord) (int, error) {
+func findMaxValue(column []*api.SelectedRecord) (int, error) {
        var ret int
 
        for _, c := range column {
diff --git a/display/graph/graph.go b/pkg/display/graph/graph.go
similarity index 79%
rename from display/graph/graph.go
rename to pkg/display/graph/graph.go
index 22aad02..c05b2c0 100644
--- a/display/graph/graph.go
+++ b/pkg/display/graph/graph.go
@@ -22,25 +22,26 @@ import (
        "reflect"
        "strings"
 
+       "github.com/apache/skywalking-cli/api"
+
        "github.com/urfave/cli"
 
-       d "github.com/apache/skywalking-cli/display/displayable"
-       db "github.com/apache/skywalking-cli/display/graph/dashboard"
-       "github.com/apache/skywalking-cli/display/graph/gauge"
-       "github.com/apache/skywalking-cli/display/graph/heatmap"
-       "github.com/apache/skywalking-cli/display/graph/linear"
-       "github.com/apache/skywalking-cli/display/graph/tree"
-       "github.com/apache/skywalking-cli/graphql/dashboard"
-       "github.com/apache/skywalking-cli/graphql/schema"
+       d "github.com/apache/skywalking-cli/pkg/display/displayable"
+       db "github.com/apache/skywalking-cli/pkg/display/graph/dashboard"
+       "github.com/apache/skywalking-cli/pkg/display/graph/gauge"
+       "github.com/apache/skywalking-cli/pkg/display/graph/heatmap"
+       "github.com/apache/skywalking-cli/pkg/display/graph/linear"
+       "github.com/apache/skywalking-cli/pkg/display/graph/tree"
+       "github.com/apache/skywalking-cli/pkg/graphql/dashboard"
 )
 
 type (
-       Thermodynamic      = schema.HeatMap
+       Thermodynamic      = api.HeatMap
        LinearMetrics      = map[string]float64
        MultiLinearMetrics = []LinearMetrics
-       Trace              = schema.Trace
-       TraceBrief         = schema.TraceBrief
-       GlobalMetrics      = [][]*schema.SelectedRecord
+       Trace              = api.Trace
+       TraceBrief         = api.TraceBrief
+       GlobalMetrics      = [][]*api.SelectedRecord
        GlobalData         = dashboard.GlobalData
 )
 
diff --git a/display/graph/heatmap/heatmap.go 
b/pkg/display/graph/heatmap/heatmap.go
similarity index 86%
rename from display/graph/heatmap/heatmap.go
rename to pkg/display/graph/heatmap/heatmap.go
index 12f64d4..1416077 100644
--- a/display/graph/heatmap/heatmap.go
+++ b/pkg/display/graph/heatmap/heatmap.go
@@ -22,6 +22,8 @@ import (
        "fmt"
        "strings"
 
+       "github.com/apache/skywalking-cli/api"
+
        "github.com/mum4k/termdash"
        "github.com/mum4k/termdash/container"
        "github.com/mum4k/termdash/container/grid"
@@ -30,15 +32,14 @@ import (
        "github.com/mum4k/termdash/terminal/terminalapi"
        "github.com/mum4k/termdash/widgetapi"
 
-       d "github.com/apache/skywalking-cli/display/displayable"
-       "github.com/apache/skywalking-cli/graphql/schema"
-       "github.com/apache/skywalking-cli/graphql/utils"
-       "github.com/apache/skywalking-cli/lib/heatmap"
+       d "github.com/apache/skywalking-cli/pkg/display/displayable"
+       "github.com/apache/skywalking-cli/pkg/graphql/utils"
+       "github.com/apache/skywalking-cli/pkg/heatmap"
 )
 
 const rootID = "root"
 
-func NewHeatMapWidget(data schema.HeatMap) (hp *heatmap.HeatMap, err error) {
+func NewHeatMapWidget(data api.HeatMap) (hp *heatmap.HeatMap, err error) {
        hp, err = heatmap.NewHeatMap()
        if err != nil {
                return hp, err
@@ -48,14 +49,14 @@ func NewHeatMapWidget(data schema.HeatMap) (hp 
*heatmap.HeatMap, err error) {
        return
 }
 
-func SetData(hp *heatmap.HeatMap, data schema.HeatMap) {
+func SetData(hp *heatmap.HeatMap, data api.HeatMap) {
        hpColumns, yLabels := processData(data)
        hp.SetColumns(hpColumns)
        hp.SetYLabels(yLabels)
 }
 
 // processData converts data into hpColumns and yValues for the heat map.
-func processData(data schema.HeatMap) (hpColumns map[string][]int64, yLabels 
[]string) {
+func processData(data api.HeatMap) (hpColumns map[string][]int64, yLabels 
[]string) {
        hpColumns = utils.HeatMapToMap(&data)
        yLabels = utils.BucketsToStrings(data.Buckets)
        return
@@ -97,7 +98,7 @@ func Display(displayable *d.Displayable) error {
                return err
        }
 
-       data := displayable.Data.(schema.HeatMap)
+       data := displayable.Data.(api.HeatMap)
        hp, err := NewHeatMapWidget(data)
        if err != nil {
                return err
diff --git a/display/graph/linear/linear.go b/pkg/display/graph/linear/linear.go
similarity index 100%
rename from display/graph/linear/linear.go
rename to pkg/display/graph/linear/linear.go
diff --git a/display/graph/tree/adapter.go b/pkg/display/graph/tree/adapter.go
similarity index 89%
rename from display/graph/tree/adapter.go
rename to pkg/display/graph/tree/adapter.go
index 895b5fd..7e4758c 100644
--- a/display/graph/tree/adapter.go
+++ b/pkg/display/graph/tree/adapter.go
@@ -21,11 +21,12 @@ import (
        "fmt"
        "strings"
 
-       "github.com/apache/skywalking-cli/graphql/schema"
-       "github.com/apache/skywalking-cli/util"
+       "github.com/apache/skywalking-cli/api"
+
+       "github.com/apache/skywalking-cli/pkg/util"
 )
 
-func Adapt(trace schema.Trace) (roots []*Node, serviceNames []string) {
+func Adapt(trace api.Trace) (roots []*Node, serviceNames []string) {
        all := make(map[string]*Node)
        set := make(map[string]bool)
        var traceID string
@@ -73,7 +74,7 @@ func Adapt(trace schema.Trace) (roots []*Node, serviceNames 
[]string) {
        return roots, serviceNames
 }
 
-func buildTree(all map[string]*Node, seen map[string]bool, trace schema.Trace) 
{
+func buildTree(all map[string]*Node, seen map[string]bool, trace api.Trace) {
        for len(seen) < len(trace.Spans) {
                for _, span := range trace.Spans {
                        if seen[id(span)] {
@@ -96,13 +97,13 @@ func buildTree(all map[string]*Node, seen map[string]bool, 
trace schema.Trace) {
        }
 }
 
-func virtualSpan(spanID int, ref schema.Ref) *schema.Span {
+func virtualSpan(spanID int, ref api.Ref) *api.Span {
        endpointName := fmt.Sprintf("VNode: %s", ref.ParentSegmentID)
        component := fmt.Sprintf("VirtualNode: #%d", spanID)
        peer := "No Peer"
        fail := true
        layer := "Broken"
-       span := schema.Span{
+       span := api.Span{
                TraceID:      ref.TraceID,
                SegmentID:    ref.ParentSegmentID,
                SpanID:       spanID,
@@ -120,27 +121,27 @@ func virtualSpan(spanID int, ref schema.Ref) *schema.Span 
{
        return &span
 }
 
-func isRoot(span *schema.Span) bool {
+func isRoot(span *api.Span) bool {
        return span.SpanID == 0 && span.ParentSpanID == -1 && len(span.Refs) == 0
 }
 
-func id(span *schema.Span) string {
+func id(span *api.Span) string {
        return fmt.Sprintf("%s:%s:%d", span.TraceID, span.SegmentID, 
span.SpanID)
 }
 
-func pid(span *schema.Span) string {
+func pid(span *api.Span) string {
        return fmt.Sprintf("%s:%s:%d", span.TraceID, span.SegmentID, 
span.ParentSpanID)
 }
 
-func id0(ref *schema.Ref) string {
+func id0(ref *api.Ref) string {
        return fmt.Sprintf("%s:%s:%d", ref.TraceID, ref.ParentSegmentID, 
ref.ParentSpanID)
 }
 
-func id1(ref *schema.Ref) string {
+func id1(ref *api.Ref) string {
        return fmt.Sprintf("%s:%s:%d", ref.TraceID, ref.ParentSegmentID, 
ref.ParentSpanID-1)
 }
 
-func node(span *schema.Span) *Node {
+func node(span *api.Span) *Node {
        return &Node{
                Children: []*Node{},
                Value:    util.Stringify{Str: value(span)},
@@ -148,7 +149,7 @@ func node(span *schema.Span) *Node {
        }
 }
 
-func value(span *schema.Span) string {
+func value(span *api.Span) string {
        if *span.IsError {
                return fmt.Sprintf(
                        "[|%s| %s [%s/%s]](mod:bold,fg:white,bg:red)",
@@ -161,7 +162,7 @@ func value(span *schema.Span) string {
        )
 }
 
-func detail(span *schema.Span) string {
+func detail(span *api.Span) string {
        var lines []string
 
        lines = append(lines,
diff --git a/display/graph/tree/list.go b/pkg/display/graph/tree/list.go
similarity index 86%
rename from display/graph/tree/list.go
rename to pkg/display/graph/tree/list.go
index 8fa53bc..8028e79 100644
--- a/display/graph/tree/list.go
+++ b/pkg/display/graph/tree/list.go
@@ -21,15 +21,16 @@ import (
        "fmt"
        "strings"
 
-       d "github.com/apache/skywalking-cli/display/displayable"
-       "github.com/apache/skywalking-cli/graphql/schema"
-       "github.com/apache/skywalking-cli/graphql/trace"
+       "github.com/apache/skywalking-cli/api"
+
+       d "github.com/apache/skywalking-cli/pkg/display/displayable"
+       "github.com/apache/skywalking-cli/pkg/graphql/trace"
 
        ui "github.com/gizak/termui/v3"
        "github.com/gizak/termui/v3/widgets"
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/logger"
+       "github.com/apache/skywalking-cli/internal/logger"
 )
 
 const DefaultPageSize = 15
@@ -38,8 +39,8 @@ const Detail = " Detail "
 const Quit = "<C-c>"
 
 func DisplayList(ctx *cli.Context, displayable *d.Displayable) error {
-       data := displayable.Data.(schema.TraceBrief)
-       condition := displayable.Condition.(*schema.TraceQueryCondition)
+       data := displayable.Data.(api.TraceBrief)
+       condition := displayable.Condition.(*api.TraceQueryCondition)
        if err := ui.Init(); err != nil {
                logger.Log.Fatalf("failed to initialize termui: %v", err)
        }
@@ -89,8 +90,8 @@ func DisplayList(ctx *cli.Context, displayable 
*d.Displayable) error {
        return nil
 }
 
-func draw(list *widgets.List, tree *widgets.Tree, detail, help 
*widgets.Paragraph, data schema.TraceBrief,
-       ctx *cli.Context, condition *schema.TraceQueryCondition) {
+func draw(list *widgets.List, tree *widgets.Tree, detail, help 
*widgets.Paragraph, data api.TraceBrief,
+       ctx *cli.Context, condition *api.TraceQueryCondition) {
        x, y := ui.TerminalDimensions()
 
        if data.Total != 0 {
@@ -124,10 +125,11 @@ func totalPages(total int) int {
        return total/DefaultPageSize + 1
 }
 
-func listenTracesKeyboard(list *widgets.List, tree *widgets.Tree, data 
schema.TraceBrief, ctx *cli.Context,
-       detail, help *widgets.Paragraph, condition *schema.TraceQueryCondition) 
{
+func listenTracesKeyboard(list *widgets.List, tree *widgets.Tree, data 
api.TraceBrief, ctx *cli.Context,
+       detail, help *widgets.Paragraph, condition *api.TraceQueryCondition) {
        uiEvents := ui.PollEvents()
        listActive := true
+       var err error
        for {
                e := <-uiEvents
 
@@ -139,7 +141,10 @@ func listenTracesKeyboard(list *widgets.List, tree 
*widgets.Tree, data schema.Tr
                        if pageNum != 1 {
                                pageNum--
                                condition.Paging.PageNum = &pageNum
-                               data = trace.Traces(ctx, condition)
+                               data, err = trace.Traces(ctx, condition)
+                               if err != nil {
+                                       logger.Log.Fatalln(err)
+                               }
                        }
                        tree.SelectedRow = 0
                case "<C-f>", "n":
@@ -147,7 +152,10 @@ func listenTracesKeyboard(list *widgets.List, tree 
*widgets.Tree, data schema.Tr
                        if pageNum < totalPages(data.Total) {
                                pageNum++
                                condition.Paging.PageNum = &pageNum
-                               data = trace.Traces(ctx, condition)
+                               data, err = trace.Traces(ctx, condition)
+                               if err != nil {
+                                       logger.Log.Fatalln(err)
+                               }
                        }
                        tree.SelectedRow = 0
                case "<Right>":
@@ -199,7 +207,12 @@ func listActions(key string, list *widgets.List, tree 
*widgets.Tree, listActive
 }
 
 func getNodeData(ctx *cli.Context, traceID string) (nodes []*widgets.TreeNode, 
serviceNames []string) {
-       data := trace.Trace(ctx, traceID)
+       data, err := trace.Trace(ctx, traceID)
+
+       if err != nil {
+               logger.Log.Fatalln(err)
+       }
+
        var roots []*Node
        roots, serviceNames = Adapt(data)
 
@@ -214,7 +227,7 @@ func getNodeData(ctx *cli.Context, traceID string) (nodes 
[]*widgets.TreeNode, s
        return nodes, serviceNames
 }
 
-func rows(data schema.TraceBrief, subLen int) []string {
+func rows(data api.TraceBrief, subLen int) []string {
        var rows []string
 
        for _, t := range data.Traces {
diff --git a/display/graph/tree/tree.go b/pkg/display/graph/tree/tree.go
similarity index 99%
rename from display/graph/tree/tree.go
rename to pkg/display/graph/tree/tree.go
index ee0e168..916c94c 100644
--- a/display/graph/tree/tree.go
+++ b/pkg/display/graph/tree/tree.go
@@ -24,7 +24,7 @@ import (
        ui "github.com/gizak/termui/v3"
        "github.com/gizak/termui/v3/widgets"
 
-       "github.com/apache/skywalking-cli/logger"
+       "github.com/apache/skywalking-cli/internal/logger"
 )
 
 type Node struct {
diff --git a/display/json/json.go b/pkg/display/json/json.go
similarity index 94%
rename from display/json/json.go
rename to pkg/display/json/json.go
index 12a506f..e3f2cf8 100644
--- a/display/json/json.go
+++ b/pkg/display/json/json.go
@@ -21,7 +21,7 @@ import (
        "encoding/json"
        "fmt"
 
-       d "github.com/apache/skywalking-cli/display/displayable"
+       d "github.com/apache/skywalking-cli/pkg/display/displayable"
 )
 
 func Display(displayable *d.Displayable) error {
diff --git a/display/json/json_test.go b/pkg/display/json/json_test.go
similarity index 80%
rename from display/json/json_test.go
rename to pkg/display/json/json_test.go
index 9d8ead4..c4e7258 100644
--- a/display/json/json_test.go
+++ b/pkg/display/json/json_test.go
@@ -20,24 +20,24 @@ package json
 import (
        "testing"
 
-       d "github.com/apache/skywalking-cli/display/displayable"
+       "github.com/apache/skywalking-cli/api"
 
-       "github.com/apache/skywalking-cli/graphql/schema"
+       d "github.com/apache/skywalking-cli/pkg/display/displayable"
 )
 
 func TestJsonDisplay(t *testing.T) {
-       var result []schema.Service
+       var result []api.Service
        display(t, result)
-       result = make([]schema.Service, 0)
+       result = make([]api.Service, 0)
        display(t, result)
-       result = append(result, schema.Service{
+       result = append(result, api.Service{
                ID:   "1",
                Name: "json",
        })
        display(t, result)
 }
 
-func display(t *testing.T, result []schema.Service) {
+func display(t *testing.T, result []api.Service) {
        if err := Display(&d.Displayable{Data: result}); err != nil {
                t.Error(err)
        }
diff --git a/display/table/table.go b/pkg/display/table/table.go
similarity index 93%
rename from display/table/table.go
rename to pkg/display/table/table.go
index 8e2227d..0c82376 100644
--- a/display/table/table.go
+++ b/pkg/display/table/table.go
@@ -21,9 +21,9 @@ import (
        "encoding/json"
        "os"
 
-       d "github.com/apache/skywalking-cli/display/displayable"
+       d "github.com/apache/skywalking-cli/pkg/display/displayable"
 
-       "github.com/apache/skywalking-cli/logger"
+       "github.com/apache/skywalking-cli/internal/logger"
 
        "github.com/olekukonko/tablewriter"
 )
diff --git a/display/table/table_test.go b/pkg/display/table/table_test.go
similarity index 80%
rename from display/table/table_test.go
rename to pkg/display/table/table_test.go
index ec2b265..eadfcea 100644
--- a/display/table/table_test.go
+++ b/pkg/display/table/table_test.go
@@ -20,24 +20,24 @@ package table
 import (
        "testing"
 
-       "github.com/apache/skywalking-cli/display/displayable"
+       "github.com/apache/skywalking-cli/api"
 
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
 )
 
 func TestTableDisplay(t *testing.T) {
-       var result []schema.Service
+       var result []api.Service
        display(t, result)
-       result = make([]schema.Service, 0)
+       result = make([]api.Service, 0)
        display(t, result)
-       result = append(result, schema.Service{
+       result = append(result, api.Service{
                ID:   "1",
                Name: "table",
        })
        display(t, result)
 }
 
-func display(t *testing.T, result []schema.Service) {
+func display(t *testing.T, result []api.Service) {
        if err := Display(&displayable.Displayable{Data: result}); err != nil {
                t.Error(err)
        }
diff --git a/display/yaml/yaml.go b/pkg/display/yaml/yaml.go
similarity index 94%
rename from display/yaml/yaml.go
rename to pkg/display/yaml/yaml.go
index 3f3c98b..4cfe9af 100644
--- a/display/yaml/yaml.go
+++ b/pkg/display/yaml/yaml.go
@@ -20,7 +20,7 @@ package yaml
 import (
        "fmt"
 
-       d "github.com/apache/skywalking-cli/display/displayable"
+       d "github.com/apache/skywalking-cli/pkg/display/displayable"
 
        "gopkg.in/yaml.v2"
 )
diff --git a/display/yaml/yaml_test.go b/pkg/display/yaml/yaml_test.go
similarity index 80%
rename from display/yaml/yaml_test.go
rename to pkg/display/yaml/yaml_test.go
index aaada3a..d2c667d 100644
--- a/display/yaml/yaml_test.go
+++ b/pkg/display/yaml/yaml_test.go
@@ -20,24 +20,24 @@ package yaml
 import (
        "testing"
 
-       "github.com/apache/skywalking-cli/display/displayable"
+       "github.com/apache/skywalking-cli/api"
 
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
 )
 
 func TestYamlDisplay(t *testing.T) {
-       var result []schema.Service
+       var result []api.Service
        display(t, result)
-       result = make([]schema.Service, 0)
+       result = make([]api.Service, 0)
        display(t, result)
-       result = append(result, schema.Service{
+       result = append(result, api.Service{
                ID:   "1",
                Name: "yaml",
        })
        display(t, result)
 }
 
-func display(t *testing.T, result []schema.Service) {
+func display(t *testing.T, result []api.Service) {
        if err := Display(&displayable.Displayable{Data: result}); err != nil {
                t.Error(err)
        }
diff --git a/graphql/client/client.go b/pkg/graphql/client/client.go
similarity index 84%
rename from graphql/client/client.go
rename to pkg/graphql/client/client.go
index ebadd9c..0d71c8d 100644
--- a/graphql/client/client.go
+++ b/pkg/graphql/client/client.go
@@ -24,7 +24,7 @@ import (
        "github.com/machinebox/graphql"
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/logger"
+       "github.com/apache/skywalking-cli/internal/logger"
 )
 
 func newClient(cliCtx *cli.Context) (client *graphql.Client) {
@@ -52,10 +52,3 @@ func ExecuteQuery(cliCtx *cli.Context, request 
*graphql.Request, response interf
        err := client.Run(ctx, request, response)
        return err
 }
-
-// ExecuteQuery executes the `request` and parse to the `response`, panic if 
there is any `error`.
-func ExecuteQueryOrFail(cliCtx *cli.Context, request *graphql.Request, 
response interface{}) {
-       if err := ExecuteQuery(cliCtx, request, response); err != nil {
-               logger.Log.Fatalln(err)
-       }
-}
diff --git a/graphql/dashboard/global.go b/pkg/graphql/dashboard/global.go
similarity index 68%
rename from graphql/dashboard/global.go
rename to pkg/graphql/dashboard/global.go
index c004acd..1e29b30 100644
--- a/graphql/dashboard/global.go
+++ b/pkg/graphql/dashboard/global.go
@@ -23,15 +23,17 @@ import (
        "strings"
        "sync"
 
+       "github.com/apache/skywalking-cli/api"
+       "github.com/apache/skywalking-cli/internal/logger"
+
        "github.com/spf13/viper"
        "github.com/urfave/cli"
 
        "gopkg.in/yaml.v2"
 
        "github.com/apache/skywalking-cli/assets"
-       "github.com/apache/skywalking-cli/graphql/metrics"
-       "github.com/apache/skywalking-cli/graphql/schema"
-       "github.com/apache/skywalking-cli/graphql/utils"
+       "github.com/apache/skywalking-cli/pkg/graphql/metrics"
+       "github.com/apache/skywalking-cli/pkg/graphql/utils"
 )
 
 type ButtonTemplate struct {
@@ -41,18 +43,18 @@ type ButtonTemplate struct {
 }
 
 type MetricTemplate struct {
-       Condition      schema.TopNCondition `mapstructure:"condition"`
-       Title          string               `mapstructure:"title"`
-       Aggregation    string               `mapstructure:"aggregation"`
-       AggregationNum string               `mapstructure:"aggregationNum"`
+       Condition      api.TopNCondition `mapstructure:"condition"`
+       Title          string            `mapstructure:"title"`
+       Aggregation    string            `mapstructure:"aggregation"`
+       AggregationNum string            `mapstructure:"aggregationNum"`
 }
 
 type ChartTemplate struct {
-       Condition   schema.MetricsCondition `mapstructure:"condition"`
-       Title       string                  `mapstructure:"title"`
-       Unit        string                  `mapstructure:"unit"`
-       Labels      string                  `mapstructure:"labels"`
-       LabelsIndex string                  `mapstructure:"labelsIndex"`
+       Condition   api.MetricsCondition `mapstructure:"condition"`
+       Title       string               `mapstructure:"title"`
+       Unit        string               `mapstructure:"unit"`
+       Labels      string               `mapstructure:"labels"`
+       LabelsIndex string               `mapstructure:"labelsIndex"`
 }
 
 type GlobalTemplate struct {
@@ -63,9 +65,9 @@ type GlobalTemplate struct {
 }
 
 type GlobalData struct {
-       Metrics         [][]*schema.SelectedRecord `json:"metrics"`
-       ResponseLatency []map[string]float64       `json:"responseLatency"`
-       HeatMap         schema.HeatMap             `json:"heatMap"`
+       Metrics         [][]*api.SelectedRecord `json:"metrics"`
+       ResponseLatency []map[string]float64    `json:"responseLatency"`
+       HeatMap         api.HeatMap             `json:"heatMap"`
 }
 
 // Use singleton pattern to make sure to load template only once.
@@ -138,27 +140,31 @@ func getButtonTexts(byteValue []byte) ([]string, error) {
        return ret, nil
 }
 
-func Metrics(ctx *cli.Context, duration schema.Duration) 
[][]*schema.SelectedRecord {
-       var ret [][]*schema.SelectedRecord
+func Metrics(ctx *cli.Context, duration api.Duration) 
([][]*api.SelectedRecord, error) {
+       var ret [][]*api.SelectedRecord
 
        template, err := LoadTemplate(ctx.String("template"))
        if err != nil {
-               return nil
+               return nil, nil
        }
 
        // Check if there is a template of metrics.
        if template.Metrics == nil {
-               return nil
+               return nil, nil
        }
 
        for _, m := range template.Metrics {
-               ret = append(ret, metrics.SortMetrics(ctx, m.Condition, 
duration))
+               sortMetrics, err := metrics.SortMetrics(ctx, m.Condition, 
duration)
+               if err != nil {
+                       return nil, err
+               }
+               ret = append(ret, sortMetrics)
        }
 
-       return ret
+       return ret, nil
 }
 
-func responseLatency(ctx *cli.Context, duration schema.Duration) 
[]map[string]float64 {
+func responseLatency(ctx *cli.Context, duration api.Duration) 
[]map[string]float64 {
        template, err := LoadTemplate(ctx.String("template"))
        if err != nil {
                return nil
@@ -173,39 +179,49 @@ func responseLatency(ctx *cli.Context, duration 
schema.Duration) []map[string]fl
        // need use ", " to split into string array for graphql query.
        labelsIndex := strings.Split(template.ResponseLatency.LabelsIndex, ", ")
 
-       responseLatency := metrics.MultipleLinearIntValues(ctx, 
template.ResponseLatency.Condition, labelsIndex, duration)
+       responseLatency, err := metrics.MultipleLinearIntValues(ctx, 
template.ResponseLatency.Condition, labelsIndex, duration)
+
+       if err != nil {
+               logger.Log.Fatalln(err)
+       }
 
        // Convert metrics values to map type data.
        return utils.MetricsValuesArrayToMap(duration, responseLatency)
 }
 
-func heatMap(ctx *cli.Context, duration schema.Duration) schema.HeatMap {
+func heatMap(ctx *cli.Context, duration api.Duration) (api.HeatMap, error) {
        template, err := LoadTemplate(ctx.String("template"))
        if err != nil {
-               return schema.HeatMap{}
+               return api.HeatMap{}, nil
        }
 
        // Check if there is a template of heat map.
        if template.HeatMap == (ChartTemplate{}) {
-               return schema.HeatMap{}
+               return api.HeatMap{}, nil
        }
 
        return metrics.Thermodynamic(ctx, template.HeatMap.Condition, duration)
 }
 
-func Global(ctx *cli.Context, duration schema.Duration) *GlobalData {
+func Global(ctx *cli.Context, duration api.Duration) (*GlobalData, error) {
        // Load template to `globalTemplate`, so the subsequent three calls can 
ues it directly.
        _, err := LoadTemplate(ctx.String("template"))
        if err != nil {
-               return nil
+               return nil, nil
        }
 
+       errors := make(chan error)
+       done := make(chan bool)
+
        // Use three goroutines to enable concurrent execution of three graphql 
queries.
        var wg sync.WaitGroup
        wg.Add(3)
-       var m [][]*schema.SelectedRecord
+       var m [][]*api.SelectedRecord
        go func() {
-               m = Metrics(ctx, duration)
+               m, err = Metrics(ctx, duration)
+               if err != nil {
+                       errors <- err
+               }
                wg.Done()
        }()
        var rl []map[string]float64
@@ -213,17 +229,32 @@ func Global(ctx *cli.Context, duration schema.Duration) 
*GlobalData {
                rl = responseLatency(ctx, duration)
                wg.Done()
        }()
-       var hm schema.HeatMap
+       var hm api.HeatMap
        go func() {
-               hm = heatMap(ctx, duration)
+               hm, err = heatMap(ctx, duration)
+               if err != nil {
+                       errors <- err
+               }
                wg.Done()
        }()
-       wg.Wait()
+
+       go func() {
+               wg.Wait()
+               close(done)
+       }()
+
+       select {
+       case <-done:
+               break
+       case err := <-errors:
+               close(errors)
+               return nil, err
+       }
 
        var globalData GlobalData
        globalData.Metrics = m
        globalData.ResponseLatency = rl
        globalData.HeatMap = hm
 
-       return &globalData
+       return &globalData, nil
 }
diff --git a/graphql/common/common.go b/pkg/graphql/healthcheck/healthcheck.go
similarity index 71%
rename from graphql/common/common.go
rename to pkg/graphql/healthcheck/healthcheck.go
index 1f1c417..3f0348f 100644
--- a/graphql/common/common.go
+++ b/pkg/graphql/healthcheck/healthcheck.go
@@ -15,24 +15,25 @@
 // specific language governing permissions and limitations
 // under the License.
 
-package common
+package healthcheck
 
 import (
        "github.com/machinebox/graphql"
        "github.com/urfave/cli"
 
+       "github.com/apache/skywalking-cli/api"
+
        "github.com/apache/skywalking-cli/assets"
-       "github.com/apache/skywalking-cli/graphql/client"
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/pkg/graphql/client"
 )
 
 // CheckHealth intends to query the health status of OAP server
-func CheckHealth(ctx *cli.Context) schema.HealthStatus {
-       var response map[string]schema.HealthStatus
+func CheckHealth(ctx *cli.Context) (api.HealthStatus, error) {
+       var response map[string]api.HealthStatus
 
-       request := 
graphql.NewRequest(assets.Read("graphqls/common/checkHealth.graphql"))
+       request := 
graphql.NewRequest(assets.Read("graphqls/healthcheck/healthcheck.graphql"))
 
-       client.ExecuteQueryOrFail(ctx, request, &response)
+       err := client.ExecuteQuery(ctx, request, &response)
 
-       return response["checkHealth"]
+       return response["checkHealth"], err
 }
diff --git a/graphql/metadata/metadata.go b/pkg/graphql/metadata/metadata.go
similarity index 66%
rename from graphql/metadata/metadata.go
rename to pkg/graphql/metadata/metadata.go
index 49e88be..f29577e 100644
--- a/graphql/metadata/metadata.go
+++ b/pkg/graphql/metadata/metadata.go
@@ -20,32 +20,34 @@ package metadata
 import (
        "fmt"
 
+       "github.com/apache/skywalking-cli/api"
+
        "github.com/apache/skywalking-cli/assets"
 
        "github.com/machinebox/graphql"
        "github.com/urfave/cli"
 
-       "github.com/apache/skywalking-cli/graphql/client"
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/pkg/graphql/client"
 )
 
-func AllServices(cliCtx *cli.Context, duration schema.Duration) 
[]schema.Service {
-       var response map[string][]schema.Service
+func AllServices(cliCtx *cli.Context, duration api.Duration) ([]api.Service, 
error) {
+       var response map[string][]api.Service
 
        request := 
graphql.NewRequest(assets.Read("graphqls/metadata/AllServices.graphql"))
        request.Var("duration", duration)
 
-       client.ExecuteQueryOrFail(cliCtx, request, &response)
-       return response["result"]
+       err := client.ExecuteQuery(cliCtx, request, &response)
+
+       return response["result"], err
 }
 
-func SearchService(cliCtx *cli.Context, serviceCode string) (service 
schema.Service, err error) {
-       var response map[string]schema.Service
+func SearchService(cliCtx *cli.Context, serviceCode string) (service 
api.Service, err error) {
+       var response map[string]api.Service
 
        request := 
graphql.NewRequest(assets.Read("graphqls/metadata/SearchService.graphql"))
        request.Var("serviceCode", serviceCode)
 
-       client.ExecuteQueryOrFail(cliCtx, request, &response)
+       err = client.ExecuteQuery(cliCtx, request, &response)
 
        service = response["result"]
 
@@ -53,41 +55,41 @@ func SearchService(cliCtx *cli.Context, serviceCode string) 
(service schema.Serv
                return service, fmt.Errorf("no such service [%s]", serviceCode)
        }
 
-       return service, nil
+       return service, err
 }
 
-func SearchEndpoints(cliCtx *cli.Context, serviceID, keyword string, limit 
int) []schema.Endpoint {
-       var response map[string][]schema.Endpoint
+func SearchEndpoints(cliCtx *cli.Context, serviceID, keyword string, limit 
int) ([]api.Endpoint, error) {
+       var response map[string][]api.Endpoint
 
        request := 
graphql.NewRequest(assets.Read("graphqls/metadata/SearchEndpoints.graphql"))
        request.Var("serviceId", serviceID)
        request.Var("keyword", keyword)
        request.Var("limit", limit)
 
-       client.ExecuteQueryOrFail(cliCtx, request, &response)
+       err := client.ExecuteQuery(cliCtx, request, &response)
 
-       return response["result"]
+       return response["result"], err
 }
 
-func Instances(cliCtx *cli.Context, serviceID string, duration 
schema.Duration) []schema.ServiceInstance {
-       var response map[string][]schema.ServiceInstance
+func Instances(cliCtx *cli.Context, serviceID string, duration api.Duration) 
([]api.ServiceInstance, error) {
+       var response map[string][]api.ServiceInstance
 
        request := 
graphql.NewRequest(assets.Read("graphqls/metadata/Instances.graphql"))
        request.Var("serviceId", serviceID)
        request.Var("duration", duration)
 
-       client.ExecuteQueryOrFail(cliCtx, request, &response)
+       err := client.ExecuteQuery(cliCtx, request, &response)
 
-       return response["result"]
+       return response["result"], err
 }
 
-func ServerTimeInfo(cliCtx *cli.Context) (schema.TimeInfo, error) {
-       var response map[string]schema.TimeInfo
+func ServerTimeInfo(cliCtx *cli.Context) (api.TimeInfo, error) {
+       var response map[string]api.TimeInfo
 
        request := 
graphql.NewRequest(assets.Read("graphqls/metadata/ServerTimeInfo.graphql"))
 
        if err := client.ExecuteQuery(cliCtx, request, &response); err != nil {
-               return schema.TimeInfo{}, err
+               return api.TimeInfo{}, err
        }
 
        return response["result"], nil
diff --git a/graphql/metrics/metrics.go b/pkg/graphql/metrics/metrics.go
similarity index 56%
rename from graphql/metrics/metrics.go
rename to pkg/graphql/metrics/metrics.go
index 8a73a58..85073bd 100644
--- a/graphql/metrics/metrics.go
+++ b/pkg/graphql/metrics/metrics.go
@@ -18,15 +18,15 @@
 package metrics
 
 import (
-       "github.com/apache/skywalking-cli/assets"
-       "github.com/apache/skywalking-cli/graphql/client"
-       "github.com/apache/skywalking-cli/graphql/schema"
-
        "github.com/machinebox/graphql"
        "github.com/urfave/cli"
+
+       "github.com/apache/skywalking-cli/api"
+       "github.com/apache/skywalking-cli/assets"
+       "github.com/apache/skywalking-cli/pkg/graphql/client"
 )
 
-func IntValues(ctx *cli.Context, condition schema.MetricsCondition, duration 
schema.Duration) int {
+func IntValues(ctx *cli.Context, condition api.MetricsCondition, duration 
api.Duration) (int, error) {
        var response map[string]int
 
        request := 
graphql.NewRequest(assets.Read("graphqls/metrics/MetricsValue.graphql"))
@@ -34,26 +34,26 @@ func IntValues(ctx *cli.Context, condition 
schema.MetricsCondition, duration sch
        request.Var("condition", condition)
        request.Var("duration", duration)
 
-       client.ExecuteQueryOrFail(ctx, request, &response)
+       err := client.ExecuteQuery(ctx, request, &response)
 
-       return response["result"]
+       return response["result"], err
 }
 
-func LinearIntValues(ctx *cli.Context, condition schema.MetricsCondition, 
duration schema.Duration) schema.MetricsValues {
-       var response map[string]schema.MetricsValues
+func LinearIntValues(ctx *cli.Context, condition api.MetricsCondition, 
duration api.Duration) (api.MetricsValues, error) {
+       var response map[string]api.MetricsValues
 
        request := 
graphql.NewRequest(assets.Read("graphqls/metrics/MetricsValues.graphql"))
 
        request.Var("condition", condition)
        request.Var("duration", duration)
 
-       client.ExecuteQueryOrFail(ctx, request, &response)
+       err := client.ExecuteQuery(ctx, request, &response)
 
-       return response["result"]
+       return response["result"], err
 }
 
-func MultipleLinearIntValues(ctx *cli.Context, condition 
schema.MetricsCondition, labels []string, duration schema.Duration) 
[]schema.MetricsValues {
-       var response map[string][]schema.MetricsValues
+func MultipleLinearIntValues(ctx *cli.Context, condition api.MetricsCondition, 
labels []string, duration api.Duration) ([]api.MetricsValues, error) {
+       var response map[string][]api.MetricsValues
 
        request := 
graphql.NewRequest(assets.Read("graphqls/metrics/LabeledMetricsValues.graphql"))
 
@@ -61,42 +61,42 @@ func MultipleLinearIntValues(ctx *cli.Context, condition 
schema.MetricsCondition
        request.Var("condition", condition)
        request.Var("labels", labels)
 
-       client.ExecuteQueryOrFail(ctx, request, &response)
+       err := client.ExecuteQuery(ctx, request, &response)
 
-       return response["result"]
+       return response["result"], err
 }
 
-func Thermodynamic(ctx *cli.Context, condition schema.MetricsCondition, 
duration schema.Duration) schema.HeatMap {
-       var response map[string]schema.HeatMap
+func Thermodynamic(ctx *cli.Context, condition api.MetricsCondition, duration 
api.Duration) (api.HeatMap, error) {
+       var response map[string]api.HeatMap
 
        request := 
graphql.NewRequest(assets.Read("graphqls/metrics/HeatMap.graphql"))
 
        request.Var("condition", condition)
        request.Var("duration", duration)
 
-       client.ExecuteQueryOrFail(ctx, request, &response)
+       err := client.ExecuteQuery(ctx, request, &response)
 
-       return response["result"]
+       return response["result"], err
 }
 
-func SortMetrics(ctx *cli.Context, condition schema.TopNCondition, duration 
schema.Duration) []*schema.SelectedRecord {
-       var response map[string][]*schema.SelectedRecord
+func SortMetrics(ctx *cli.Context, condition api.TopNCondition, duration 
api.Duration) ([]*api.SelectedRecord, error) {
+       var response map[string][]*api.SelectedRecord
 
        request := 
graphql.NewRequest(assets.Read("graphqls/metrics/SortMetrics.graphql"))
        request.Var("condition", condition)
        request.Var("duration", duration)
 
-       client.ExecuteQueryOrFail(ctx, request, &response)
+       err := client.ExecuteQuery(ctx, request, &response)
 
-       return response["result"]
+       return response["result"], err
 }
 
-func ListMetrics(ctx *cli.Context, regex string) []*schema.MetricDefinition {
-       var response map[string][]*schema.MetricDefinition
+func ListMetrics(ctx *cli.Context, regex string) ([]*api.MetricDefinition, 
error) {
+       var response map[string][]*api.MetricDefinition
        request := 
graphql.NewRequest(assets.Read("graphqls/metrics/ListMetrics.graphql"))
        request.Var("regex", regex)
 
-       client.ExecuteQueryOrFail(ctx, request, &response)
+       err := client.ExecuteQuery(ctx, request, &response)
 
-       return response["result"]
+       return response["result"], err
 }
diff --git a/graphql/trace/trace.go b/pkg/graphql/trace/trace.go
similarity index 70%
rename from graphql/trace/trace.go
rename to pkg/graphql/trace/trace.go
index fab21e7..bf45f95 100644
--- a/graphql/trace/trace.go
+++ b/pkg/graphql/trace/trace.go
@@ -21,29 +21,30 @@ import (
        "github.com/machinebox/graphql"
        "github.com/urfave/cli"
 
+       "github.com/apache/skywalking-cli/api"
+
        "github.com/apache/skywalking-cli/assets"
-       "github.com/apache/skywalking-cli/graphql/client"
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/pkg/graphql/client"
 )
 
-func Trace(ctx *cli.Context, traceID string) schema.Trace {
-       var response map[string]schema.Trace
+func Trace(ctx *cli.Context, traceID string) (api.Trace, error) {
+       var response map[string]api.Trace
 
        request := 
graphql.NewRequest(assets.Read("graphqls/trace/Trace.graphql"))
        request.Var("traceId", traceID)
 
-       client.ExecuteQueryOrFail(ctx, request, &response)
+       err := client.ExecuteQuery(ctx, request, &response)
 
-       return response["result"]
+       return response["result"], err
 }
 
-func Traces(ctx *cli.Context, condition *schema.TraceQueryCondition) 
schema.TraceBrief {
-       var response map[string]schema.TraceBrief
+func Traces(ctx *cli.Context, condition *api.TraceQueryCondition) 
(api.TraceBrief, error) {
+       var response map[string]api.TraceBrief
 
        request := 
graphql.NewRequest(assets.Read("graphqls/trace/Traces.graphql"))
        request.Var("condition", condition)
 
-       client.ExecuteQueryOrFail(ctx, request, &response)
+       err := client.ExecuteQuery(ctx, request, &response)
 
-       return response["result"]
+       return response["result"], err
 }
diff --git a/graphql/utils/adapter.go b/pkg/graphql/utils/adapter.go
similarity index 84%
rename from graphql/utils/adapter.go
rename to pkg/graphql/utils/adapter.go
index 1f5918f..e5bb575 100644
--- a/graphql/utils/adapter.go
+++ b/pkg/graphql/utils/adapter.go
@@ -22,12 +22,13 @@ import (
        "strings"
        "time"
 
-       "github.com/apache/skywalking-cli/graphql/schema"
-       "github.com/apache/skywalking-cli/logger"
+       "github.com/apache/skywalking-cli/api"
+
+       "github.com/apache/skywalking-cli/internal/logger"
 )
 
 // MetricsValuesArrayToMap converts Array of MetricsValues into a map that 
uses time as key.
-func MetricsValuesArrayToMap(duration schema.Duration, mvArray 
[]schema.MetricsValues) []map[string]float64 {
+func MetricsValuesArrayToMap(duration api.Duration, mvArray 
[]api.MetricsValues) []map[string]float64 {
        ret := make([]map[string]float64, len(mvArray))
        for _, mvs := range mvArray {
                index, err := strconv.Atoi(strings.TrimSpace(*mvs.Label))
@@ -41,7 +42,7 @@ func MetricsValuesArrayToMap(duration schema.Duration, 
mvArray []schema.MetricsV
 }
 
 // MetricsValuesToMap converts MetricsValues into a map that uses time as key.
-func MetricsValuesToMap(duration schema.Duration, metricsValues 
schema.MetricsValues) map[string]float64 {
+func MetricsValuesToMap(duration api.Duration, metricsValues 
api.MetricsValues) map[string]float64 {
        kvInts := metricsValues.Values.Values
        ret := map[string]float64{}
        format := StepFormats[duration.Step]
@@ -60,7 +61,7 @@ func MetricsValuesToMap(duration schema.Duration, 
metricsValues schema.MetricsVa
 }
 
 // HeatMapToMap converts a HeatMap into a map that uses time as key.
-func HeatMapToMap(hp *schema.HeatMap) map[string][]int64 {
+func HeatMapToMap(hp *api.HeatMap) map[string][]int64 {
        ret := make(map[string][]int64)
        for _, col := range hp.Values {
                // col.id is a string represents date, like "202007292131",
@@ -78,7 +79,7 @@ func HeatMapToMap(hp *schema.HeatMap) map[string][]int64 {
 }
 
 // BucketsToStrings extracts strings from buckets as a chart's labels.
-func BucketsToStrings(buckets []*schema.Bucket) []string {
+func BucketsToStrings(buckets []*api.Bucket) []string {
        var ret []string
        for _, b := range buckets {
                ret = append(ret, b.Min)
diff --git a/graphql/utils/adapter_test.go b/pkg/graphql/utils/adapter_test.go
similarity index 86%
rename from graphql/utils/adapter_test.go
rename to pkg/graphql/utils/adapter_test.go
index 1d8270d..a3e84ca 100644
--- a/graphql/utils/adapter_test.go
+++ b/pkg/graphql/utils/adapter_test.go
@@ -21,13 +21,13 @@ import (
        "reflect"
        "testing"
 
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/api"
 )
 
 func TestMetricsToMap(t *testing.T) {
        type args struct {
-               duration      schema.Duration
-               metricsValues schema.MetricsValues
+               duration      api.Duration
+               metricsValues api.MetricsValues
        }
        tests := []struct {
                name string
@@ -37,14 +37,14 @@ func TestMetricsToMap(t *testing.T) {
                {
                        name: "Should convert to map",
                        args: args{
-                               duration: schema.Duration{
+                               duration: api.Duration{
                                        Start: "2020-01-01 0000",
                                        End:   "2020-01-01 0007",
-                                       Step:  schema.StepMinute,
+                                       Step:  api.StepMinute,
                                },
-                               metricsValues: schema.MetricsValues{
-                                       Values: &schema.IntValues{
-                                               Values: []*schema.KVInt{
+                               metricsValues: api.MetricsValues{
+                                       Values: &api.IntValues{
+                                               Values: []*api.KVInt{
                                                        {Value: 0},
                                                        {Value: 1},
                                                        {Value: 2},
diff --git a/graphql/utils/constants.go b/pkg/graphql/utils/constants.go
similarity index 74%
rename from graphql/utils/constants.go
rename to pkg/graphql/utils/constants.go
index 2f527e3..ba1f73d 100644
--- a/graphql/utils/constants.go
+++ b/pkg/graphql/utils/constants.go
@@ -20,23 +20,23 @@ package utils
 import (
        "time"
 
-       "github.com/apache/skywalking-cli/graphql/schema"
+       "github.com/apache/skywalking-cli/api"
 )
 
 // StepFormats is a mapping from schema.Step to its time format
-var StepFormats = map[schema.Step]string{
-       schema.StepSecond: "2006-01-02 150405",
-       schema.StepMinute: "2006-01-02 1504",
-       schema.StepHour:   "2006-01-02 15",
-       schema.StepDay:    "2006-01-02",
+var StepFormats = map[api.Step]string{
+       api.StepSecond: "2006-01-02 150405",
+       api.StepMinute: "2006-01-02 1504",
+       api.StepHour:   "2006-01-02 15",
+       api.StepDay:    "2006-01-02",
 }
 
 // StepDuration is a mapping from schema.Step to its time.Duration
-var StepDuration = map[schema.Step]time.Duration{
-       schema.StepSecond: time.Second,
-       schema.StepMinute: time.Minute,
-       schema.StepHour:   time.Hour,
-       schema.StepDay:    time.Hour * 24,
+var StepDuration = map[api.Step]time.Duration{
+       api.StepSecond: time.Second,
+       api.StepMinute: time.Minute,
+       api.StepHour:   time.Hour,
+       api.StepDay:    time.Hour * 24,
 }
 
 type DurationType string
diff --git a/grpc/health.go b/pkg/healthcheck/grpc.go
similarity index 97%
rename from grpc/health.go
rename to pkg/healthcheck/grpc.go
index 3b83ad2..f4c6357 100644
--- a/grpc/health.go
+++ b/pkg/healthcheck/grpc.go
@@ -15,14 +15,14 @@
 // specific language governing permissions and limitations
 // under the License.
 
-package grpc
+package healthcheck
 
 import (
        "context"
        "crypto/tls"
        "time"
 
-       "github.com/apache/skywalking-cli/logger"
+       "github.com/apache/skywalking-cli/internal/logger"
 
        "google.golang.org/grpc"
        "google.golang.org/grpc/codes"
diff --git a/lib/heatmap/axes/axes.go b/pkg/heatmap/axes/axes.go
similarity index 100%
rename from lib/heatmap/axes/axes.go
rename to pkg/heatmap/axes/axes.go
diff --git a/lib/heatmap/axes/label.go b/pkg/heatmap/axes/label.go
similarity index 100%
rename from lib/heatmap/axes/label.go
rename to pkg/heatmap/axes/label.go
diff --git a/lib/heatmap/heatmap.go b/pkg/heatmap/heatmap.go
similarity index 99%
rename from lib/heatmap/heatmap.go
rename to pkg/heatmap/heatmap.go
index cdc466f..5c87730 100644
--- a/lib/heatmap/heatmap.go
+++ b/pkg/heatmap/heatmap.go
@@ -25,7 +25,7 @@ import (
        "sort"
        "sync"
 
-       "github.com/apache/skywalking-cli/lib/heatmap/axes"
+       "github.com/apache/skywalking-cli/pkg/heatmap/axes"
 
        "github.com/mum4k/termdash/cell"
        "github.com/mum4k/termdash/private/area"
diff --git a/lib/heatmap/options.go b/pkg/heatmap/options.go
similarity index 100%
rename from lib/heatmap/options.go
rename to pkg/heatmap/options.go
diff --git a/util/io.go b/pkg/util/io.go
similarity index 96%
rename from util/io.go
rename to pkg/util/io.go
index ee65b8e..3e957f4 100644
--- a/util/io.go
+++ b/pkg/util/io.go
@@ -21,7 +21,7 @@ import (
        "os/user"
        "strings"
 
-       "github.com/apache/skywalking-cli/logger"
+       "github.com/apache/skywalking-cli/internal/logger"
 )
 
 // UserHomeDir returns the current user's home directory absolute path,
diff --git a/util/lang.go b/pkg/util/lang.go
similarity index 100%
rename from util/lang.go
rename to pkg/util/lang.go
diff --git a/util/math.go b/pkg/util/math.go
similarity index 100%
rename from util/math.go
rename to pkg/util/math.go
diff --git a/hack/boilerplate.go.txt b/scripts/boilerplate.go.txt
similarity index 100%
rename from hack/boilerplate.go.txt
rename to scripts/boilerplate.go.txt
diff --git a/hack/build-header.sh b/scripts/build-header.sh
similarity index 100%
rename from hack/build-header.sh
rename to scripts/build-header.sh
diff --git a/test/test_commands.sh b/scripts/test_commands.sh
similarity index 100%
rename from test/test_commands.sh
rename to scripts/test_commands.sh

Reply via email to