Skip to content

refactor: update Makefile and improve README, add pinger functionality - #20

Merged
kazeburo merged 5 commits into
masterfrom
feat/refactor-flagrun
Aug 18, 2026
Merged

refactor: update Makefile and improve README, add pinger functionality#20
kazeburo merged 5 commits into
masterfrom
feat/refactor-flagrun

Conversation

@kazeburo

@kazeburo kazeburo commented Aug 17, 2026

Copy link
Copy Markdown
Member

User description

  • Simplified Makefile to remove unnecessary GITCOMMIT variable.
  • Enhanced README with installation instructions and usage examples.
  • Refactored main.go to improve error handling and streamline the pinging process.
  • Added pinger.go for IP address resolution and pinger creation.
  • Removed main_test.go and added pinger_test.go for testing the new pinger functionality.
  • Updated go.mod and go.sum to include new dependencies.

PR Type

Enhancement, Tests, Documentation


Description

  • Integrates flagrun for CLI execution

  • Refactors IP resolution and pinger creation

  • Adds IPv4 and IPv6 pinger tests

  • Expands installation, configuration, and metrics documentation


Diagram Walkthrough

flowchart LR
  CLI["flagrun CLI execution"] --> PING["Resolve host and create pinger"]
  PING --> METRICS["Collect ping results and RTT metrics"]
  DOCS["README usage documentation"] --> CLI
  TESTS["IPv4 and IPv6 tests"] --> PING
Loading

File Walkthrough

Relevant files
Enhancement
main.go
Integrate flagrun into plugin execution                                   

main.go

  • Replaces custom argument parsing with flagrun
  • Implements the Run interface and exit statuses
  • Routes runtime errors to standard error
  • Removes embedded IP resolution and version handling
+11/-79 
pinger.go
Add protocol-aware pinger creation                                             

pinger.go

  • Adds reusable host resolution and pinger creation
  • Detects IPv4 and IPv6 from resolved addresses
  • Configures protocol-specific local bind addresses
+25/-0   
Tests
pinger_test.go
Test IPv4 and IPv6 pinger setup                                                   

pinger_test.go

  • Tests IPv4 address resolution and pinger creation
  • Tests IPv6 address resolution and pinger creation
  • Skips tests when ICMP privileges are unavailable
[link]   
Configuration changes
Makefile
Simplify builds and add linting                                                   

Makefile

  • Removes Git commit metadata from build flags
  • Builds all Go source files
  • Adds lint and expands phony targets
+7/-5     
Documentation
README.md
Expand Japanese usage and metrics documentation                   

README.md

  • Adds Japanese installation and usage instructions
  • Documents agent configuration and security permissions
  • Describes emitted metrics and preflight behavior
  • Includes IPv4 and IPv6 support details
+64/-3   
Dependencies
go.mod
Update CLI and networking dependencies                                     

go.mod

  • Adds the flagrun dependency
  • Updates stats and networking dependencies
  • Marks command-line parsing dependencies as indirect
+7/-4     

- Simplified Makefile to remove unnecessary GITCOMMIT variable.
- Enhanced README with installation instructions and usage examples.
- Refactored main.go to improve error handling and streamline the pinging process.
- Added pinger.go for IP address resolution and pinger creation.
- Removed main_test.go and added pinger_test.go for testing the new pinger functionality.
- Updated go.mod and go.sum to include new dependencies.
Copilot AI lite review requested due to automatic review settings August 17, 2026 13:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit 0d617a3)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

IPv6 Test Failure

The test only skips when pinger creation fails due to permission errors. On IPv4-only systems or CI environments with IPv6 disabled, creating the IPv6 pinger can fail with errors such as EAFNOSUPPORT, causing go test ./... to fail even though the IPv4 functionality works. Handle unsupported IPv6 errors as a skip, or avoid requiring IPv6 support in the default test suite.

ipv6Addr := "2001:4860:4860::8888"
ipv6IPAddr, ipv6Pinger, err := resolveIPAddrAndPinger(ipv6Addr)
if err != nil {
	if os.IsPermission(err) || errors.Is(err, syscall.EPERM) || errors.Is(err, syscall.EACCES) {
		t.Skipf("skipping: requires privileges to create ICMP sockets: %v", err)
	}
	t.Fatalf("failed to resolve IPv6 address: %v", err)

Comment thread pinger.go Outdated
Comment thread main.go
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 7e9d4e8

Comment thread pinger.go Outdated
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit d55162f

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 1e51cd1

Comment thread README.md Outdated
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 0d617a3

@github-actions

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

No code suggestions found for the PR.

@kazeburo
kazeburo merged commit 97d0cfd into master Aug 18, 2026
3 checks passed
@github-actions github-actions Bot mentioned this pull request Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants