Skip to content

Commit

Permalink
Merge pull request #10 from grishy/goland-cleanup
Browse files Browse the repository at this point in the history
chore: format code with Goland
  • Loading branch information
grishy committed Dec 1, 2023
2 parents 706c6cf + 7220ae8 commit 4ed9c71
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ go.work
# Build output
/go-avahi-cname
dist/

# Idea
.idea
3 changes: 3 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# https://github.com/goreleaser/goreleaser/pull/4391
version: 1

report_sizes: true

builds:
Expand Down
2 changes: 1 addition & 1 deletion avahi/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewPublisher() (*Publisher, error) {
fqdn := dns.Fqdn(avahiFqdn)

// RDATA: a variable length string of octets that describes the resource. CNAME in our case
// Plus 1 because it will add null byte at the end
// Plus 1 because it will add a null byte at the end.
rdataField := make([]byte, len(fqdn)+1)
_, err = dns.PackDomainName(fqdn, rdataField, 0, nil, false)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions cmd/cname.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"log"
"time"

"github.com/grishy/go-avahi-cname/avahi"
"github.com/miekg/dns"
"github.com/urfave/cli/v2"

"github.com/grishy/go-avahi-cname/avahi"
)

// formatCname formats CNAMEs by ensuring they are fully qualified domain names (FQDNs).
Expand Down Expand Up @@ -66,7 +67,7 @@ func runCname(ctx context.Context, publisher *avahi.Publisher, cnames []string,
return publishing(ctx, publisher, formattedCname, ttl, interval)
}

func CmdCname(ctx context.Context) *cli.Command {
func Cname(ctx context.Context) *cli.Command {
return &cli.Command{
Name: "cname",
Usage: "Announce CNAME records for host via avahi-daemon",
Expand Down
5 changes: 3 additions & 2 deletions cmd/subdomain.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"net"
"strings"

"github.com/grishy/go-avahi-cname/avahi"
"github.com/miekg/dns"
"github.com/urfave/cli/v2"

"github.com/grishy/go-avahi-cname/avahi"
)

type dnsMsg struct {
Expand Down Expand Up @@ -125,7 +126,7 @@ func runSubdomain(ctx context.Context, publisher *avahi.Publisher, fqdn string,
return nil
}

func CmdSubdomain(ctx context.Context) *cli.Command {
func Subdomain(ctx context.Context) *cli.Command {
return &cli.Command{
Name: "subdomain",
Usage: "Listen for all queries and publish CNAMEs for subdomains",
Expand Down
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"os/signal"

"github.com/carlmjohnson/versioninfo"
"github.com/grishy/go-avahi-cname/cmd"
"github.com/urfave/cli/v2"

"github.com/grishy/go-avahi-cname/cmd"
)

func main() {
Expand All @@ -20,8 +21,8 @@ func main() {
Usage: "A tool for publishing CNAME records with Avahi",
Version: versioninfo.Short(),
Commands: []*cli.Command{
cmd.CmdCname(ctx),
cmd.CmdSubdomain(ctx),
cmd.Cname(ctx),
cmd.Subdomain(ctx),
},
}

Expand Down

0 comments on commit 4ed9c71

Please sign in to comment.