Skip to content

Commit a9b868a

Browse files
committed
Add qr code support
1 parent b418c05 commit a9b868a

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.21.1
44

55
require (
66
github.com/schollz/progressbar/v3 v3.14.1
7+
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
78
github.com/urfave/cli/v2 v2.25.7
89
)
910

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf
1515
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
1616
github.com/schollz/progressbar/v3 v3.14.1 h1:VD+MJPCr4s3wdhTc7OEJ/Z3dAeBzJ7yKH/P4lC5yRTI=
1717
github.com/schollz/progressbar/v3 v3.14.1/go.mod h1:Zc9xXneTzWXF81TGoqL71u0sBPjULtEHYtj/WVgVy8E=
18+
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
19+
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
1820
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
1921
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
2022
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=

main.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/chyok/st/internal/pkg/discovery"
1010
"github.com/chyok/st/internal/pkg/transfer"
1111
"github.com/chyok/st/template"
12+
"github.com/skip2/go-qrcode"
1213

1314
"github.com/urfave/cli/v2"
1415
)
@@ -24,7 +25,10 @@ func sendFile(c *cli.Context) error {
2425
}
2526

2627
func receiveFile(c *cli.Context) error {
27-
fmt.Println("server address: http://" + config.G.LocalIP + ":" + config.G.Port)
28+
address := fmt.Sprintf("http://%s:%s", config.G.LocalIP, config.G.Port)
29+
q, _ := qrcode.New(address, qrcode.Low)
30+
fmt.Println(q.ToSmallString(false))
31+
fmt.Printf("Server address: %s \n", address)
2832
fmt.Println("Waiting transfer...")
2933
go discovery.Listen(config.G.MulticastAddress)
3034
http.HandleFunc("/", transfer.ReceiveFileHandler)

0 commit comments

Comments
 (0)