Commit 01ea6002 authored by Michael Yang's avatar Michael Yang
Browse files

replace go-humanize with format.HumanBytes

parent 42386204
...@@ -20,7 +20,6 @@ import ( ...@@ -20,7 +20,6 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/dustin/go-humanize"
"github.com/olekukonko/tablewriter" "github.com/olekukonko/tablewriter"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
...@@ -173,7 +172,7 @@ func ListHandler(cmd *cobra.Command, args []string) error { ...@@ -173,7 +172,7 @@ func ListHandler(cmd *cobra.Command, args []string) error {
for _, m := range models.Models { for _, m := range models.Models {
if len(args) == 0 || strings.HasPrefix(m.Name, args[0]) { if len(args) == 0 || strings.HasPrefix(m.Name, args[0]) {
data = append(data, []string{m.Name, m.Digest[:12], humanize.Bytes(uint64(m.Size)), format.HumanTime(m.ModifiedAt, "Never")}) data = append(data, []string{m.Name, m.Digest[:12], format.HumanBytes(m.Size), format.HumanTime(m.ModifiedAt, "Never")})
} }
} }
......
...@@ -12,11 +12,11 @@ const ( ...@@ -12,11 +12,11 @@ const (
func HumanBytes(b int64) string { func HumanBytes(b int64) string {
switch { switch {
case b > GigaByte: case b > GigaByte:
return fmt.Sprintf("%d GB", b/GigaByte) return fmt.Sprintf("%.1f GB", float64(b)/GigaByte)
case b > MegaByte: case b > MegaByte:
return fmt.Sprintf("%d MB", b/MegaByte) return fmt.Sprintf("%.1f MB", float64(b)/MegaByte)
case b > KiloByte: case b > KiloByte:
return fmt.Sprintf("%d KB", b/KiloByte) return fmt.Sprintf("%.1f KB", float64(b)/KiloByte)
default: default:
return fmt.Sprintf("%d B", b) return fmt.Sprintf("%d B", b)
} }
......
...@@ -3,7 +3,6 @@ module github.com/jmorganca/ollama ...@@ -3,7 +3,6 @@ module github.com/jmorganca/ollama
go 1.20 go 1.20
require ( require (
github.com/dustin/go-humanize v1.0.1
github.com/emirpasic/gods v1.18.1 github.com/emirpasic/gods v1.18.1
github.com/gin-gonic/gin v1.9.1 github.com/gin-gonic/gin v1.9.1
github.com/mattn/go-runewidth v0.0.14 github.com/mattn/go-runewidth v0.0.14
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment