Skip to content

Commit

Permalink
WalkerNode.Path method is changed / separator (#262)
Browse files Browse the repository at this point in the history
* change / for test

* filepath -> path

* update

* update
  • Loading branch information
ddddddO authored Dec 2, 2023
1 parent d07af68 commit d604aac
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 25 deletions.
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ $ gtree web

# CLI

> [!NOTE]
> WASM binary with WASI support are also available.
> Basically, the usage is the same as the CLI built with Go.
> Please refer [here](https://github.com/ddddddO/gtree/blob/master/README_wasi_wasm.md) for usage.
## Installation

<pre>
Expand Down Expand Up @@ -98,9 +93,6 @@ $ port install gtree
<a href="https://github.com/aquaproj/aqua-registry/blob/main/pkgs/ddddddO/gtree/pkg.yaml"><b>aqua</b></a>
$ aqua g -i ddddddO/gtree

<a href="https://github.com/ddddddO/gtree/releases"><b>WASI</b></a>
$ Go to GitHub releases and Download `gtree.wasm`

<a href="https://github.com/ddddddO/gtree/pkgs/container/gtree"><b>Docker</b></a>
$ docker pull ghcr.io/ddddddo/gtree:latest
$ docker run ghcr.io/ddddddo/gtree:latest template | docker run -i ghcr.io/ddddddo/gtree:latest output
Expand Down Expand Up @@ -1302,6 +1294,7 @@ ok command-line-arguments 30.670s
- [Goでtreeを表現する](https://zenn.dev/ddddddo/articles/8cd85c68763f2e)
- [Markdown形式の入力からtreeを出力するCLI/Web](https://zenn.dev/ddddddo/articles/ad97623a004496)
- [Markdown形式の入力からファイル/ディレクトリを生成するCLI/Goパッケージ](https://zenn.dev/ddddddo/articles/460d12e8c07763)
- [盆栽 (節目の記事)](https://zenn.dev/openlogi/articles/f6cc91ac413c8f)
- [感想](https://scrapbox.io/ddddddo/useful_tools)

## English
Expand Down
4 changes: 2 additions & 2 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package gtree
import (
"fmt"
"io/fs"
"path/filepath"
"path"
"strings"
)

Expand Down Expand Up @@ -88,7 +88,7 @@ func (n *Node) branch() string {
}

func (n *Node) setPath(paths ...string) {
n.brnch.path = filepath.Join(paths...)
n.brnch.path = path.Join(paths...)
}

func (n *Node) validatePath() error {
Expand Down
1 change: 1 addition & 0 deletions simple_tree_walker.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func (wn *WalkerNode) Level() uint {

// Path returns path of node in completed tree structure.
// Path is the path from the root node to this node.
// The separator is / in any OS execution environment.
func (wn *WalkerNode) Path() string {
return wn.origin.path()
}
Expand Down
29 changes: 14 additions & 15 deletions tree_handler_walk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package gtree_test
import (
"bytes"
"fmt"
"path/filepath"
"strings"
"testing"

Expand Down Expand Up @@ -129,36 +128,36 @@ WalkerNode's methods called...
Branch : ├──
Row : ├── i
Level : 2
Path : `+filepath.Clean("a/i")+"\n"+
` HasChild : true
Path : a/i
HasChild : true
WalkerNode's methods called...
Name : u
Branch : │ └──
Row : │ └── u
Level : 3
Path : `+filepath.Clean("a/i/u")+"\n"+
` HasChild : true
Path : a/i/u
HasChild : true
WalkerNode's methods called...
Name : k
Branch : │ └──
Row : │ └── k
Level : 4
Path : `+filepath.Clean("a/i/u/k")+"\n"+
` HasChild : false
Path : a/i/u/k
HasChild : false
WalkerNode's methods called...
Name : kk
Branch : └──
Row : └── kk
Level : 2
Path : `+filepath.Clean("a/kk")+"\n"+
` HasChild : true
Path : a/kk
HasChild : true
WalkerNode's methods called...
Name : t
Branch : └──
Row : └── t
Level : 3
Path : `+filepath.Clean("a/kk/t")+"\n"+
` HasChild : false
Path : a/kk/t
HasChild : false
WalkerNode's methods called...
Name : e
Branch :
Expand All @@ -171,15 +170,15 @@ WalkerNode's methods called...
Branch : └──
Row : └── o
Level : 2
Path : `+filepath.Clean("e/o")+"\n"+
` HasChild : true
Path : e/o
HasChild : true
WalkerNode's methods called...
Name : g
Branch : └──
Row : └── g
Level : 3
Path : `+filepath.Clean("e/o/g")+"\n"+
` HasChild : false
Path : e/o/g
HasChild : false
`, "\n"),
err: nil,
},
Expand Down

0 comments on commit d604aac

Please sign in to comment.