jedib0t / go-pretty

Table-writer and more in golang!
MIT License
3.02k stars 119 forks source link

Header autoMerge bug #264

Closed fasnow closed 1 year ago

fasnow commented 1 year ago

when use: t.AppendHeader(table.Row{ip, ip}, table.RowConfig{AutoMerge: true}) t.SetStyle(table.StyleLight) then: image

and more table.Row{ip, ip,ip,ip,ip,ip.....} then more space image

jedib0t commented 1 year ago

Can you share the text you are using for the header?

fasnow commented 1 year ago

Can you share the text you are using for the header?

It is not a fixed value, but an ip address derived from my program's input, such as 10.0.0.10

beihai0xff commented 1 year ago

same issue. When I use table.RowConfig{AutoMerge: true} and set style table.StyleLight,

package main

import (
    "os"

    "github.com/jedib0t/go-pretty/v6/table"
)

func main() {
    rowConfigAutoMerge := table.RowConfig{AutoMerge: true}

    t := table.NewWriter()
    t.AppendHeader(table.Row{"Node", "Node", "Node", "Cluster", "Cluster", "Cluster", "Cluster"}, rowConfigAutoMerge)
    t.AppendHeader(table.Row{"IP", "Priority", "Role", "Addr", "Stratum", "State", "Offset"})
    t.SetAutoIndex(true)
    t.SetOutputMirror(os.Stdout)
    t.SetStyle(table.StyleLight)
    t.Style().Options.SeparateRows = true
    t.Render()
}
image
jedib0t commented 1 year ago

Thanks for the sample code to reproduce the bug. I'm currently traveling - so give me some time to look into this.

jedib0t commented 1 year ago

Hey @beihai0xff ... I tried running your sample code and I couldn't reproduce the bug:

image

I also tried it on go.dev/play to ensure it wasn't an environment issue: https://go.dev/play/p/bMyq8YPaFiH

image

Can you share information about your environment? Are you using the latest version of golang and this library?

beihai0xff commented 1 year ago

Hey @beihai0xff ... I tried running your sample code and I couldn't reproduce the bug:

image

I also tried it on go.dev/play to ensure it wasn't an environment issue: https://go.dev/play/p/bMyq8YPaFiH

image

Can you share information about your environment? Are you using the latest version of golang and this library?


➜  test go run main.go
┌───┬────────────────────────┬───────────────────────────────────────┐
│   │           NODE           │                  CLUSTER                 │
│   ├──────┬──────────┬──────┼─────────┬─────────┬─────────┬─────────┤
│   │   IP │ PRIORITY │ ROLE │    ADDR │ STRATUM │   STATE │  OFFSET │
├───┼──────┼──────────┼──────┼─────────┼─────────┼─────────┼─────────┤
└───┴──────┴──────────┴──────┴─────────┴─────────┴─────────┴─────────┘
➜  test go env
GO111MODULE="on"
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/admin/Library/Caches/go-build"
GOENV="/Users/admin/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/admin/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/admin/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/opt/homebrew/Cellar/go/1.20.5/libexec"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.20.5/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.5"
GCCGO="gccgo"
AR="ar"
CC="cc"
CXX="c++"
CGO_ENABLED="1"
GOMOD="/Users/admin/workspace/test/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/jw/4jy3w2c175x9jtmm017zsbz80000gn/T/go-build2184315690=/tmp/go-build -gno-record-gcc-switches -fno-common"
➜  test cat go.mod
module test

go 1.20

require github.com/jedib0t/go-pretty/v6 v6.4.6

require (
    github.com/mattn/go-runewidth v0.0.13 // indirect
    github.com/rivo/uniseg v0.2.0 // indirect
    github.com/stretchr/testify v1.8.2 // indirect
    golang.org/x/sys v0.7.0 // indirect
)
beihai0xff commented 1 year ago

my os information:

bash-3.2$ uname -a
Darwin bogon 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:19 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T8103 arm64

It is really strange, I try to run the code on iterm2 and mac terminal, with bash, sh, zsh, all of above can reproduce the bug. but if I run the code on goland terminal (use zsh), the table looks good.

image
jedib0t commented 1 year ago

Here is the code running on my iTerm2:

image

I'm running go1.19.4 on the latest version of go-pretty. Same output on bash/iTerm2 too.

I'm on an Intel MacBook though - don't think it should make a difference.

jedib0t commented 1 year ago

Try finding what font is being used in GoLand terminal, and try using the same on iTerm2?

jedib0t commented 1 year ago

Closing issue due to lack of response.