Create a basic cross-platform command execution application that can be installed on Windows and macOS, capable of executing simple system commands and returning their results.
- Create a simple installer for either Windows (.exe) or macOS (.pkg) [choose one]
- Implement basic start-on-boot functionality
Implement support for two command types:
- Network ping
- Get system info (hostname, IP address)
type Commander interface {
Ping(host string) (PingResult, error)
GetSystemInfo() (SystemInfo, error)
}
type PingResult struct {
Successful bool
Time time.Duration
}
type SystemInfo struct {
Hostname string
IPAddress string
}
- Implement a basic HTTP server to receive commands
- Return results as JSON
Example endpoint structure:
// POST /execute
type CommandRequest struct {
Type string `json:"type"` // "ping" or "sysinfo"
Payload string `json:"payload"` // For ping, this is the host
}
type CommandResponse struct {
Success bool `json:"success"`
Data interface{} `json:"data"`
Error string `json:"error,omitempty"`
}
- Main Application Structure
func main() {
commander := NewCommander()
server := &http.Server{
Addr: ":8080",
Handler: handleRequests(commander),
}
log.Fatal(server.ListenAndServe())
}
func handleRequests(cmdr Commander) http.Handler {
mux := http.NewServeMux()
mux.HandleFunc("/execute", handleCommand(cmdr))
return mux
}
func handleCommand(cmdr Commander) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Parse request and execute command
}
}
- Platform-Specific Implementation
type commander struct{}
func NewCommander() Commander {
return &commander{}
}
func (c *commander) GetSystemInfo() (SystemInfo, error) {
hostname, err := os.Hostname()
if err != nil {
return SystemInfo{}, err
}
// Get IP address (implement this)
return SystemInfo{
Hostname: hostname,
IPAddress: "implement me",
}, nil
}
-
Create a GitHub repository with your solution.
-
Source code with:
- Command execution implementation
- HTTP server implementation
- Basic installer script
-
README.md with:
- Build instructions
- API documentation
- Installation guide
- Testing
- A short clip that shows the "app in action"
func TestGetSystemInfo(t *testing.T) {
cmdr := NewCommander()
info, err := cmdr.GetSystemInfo()
if err != nil {
t.Fatalf("Expected no error, got %v", err)
}
if info.Hostname == "" {
t.Error("Expected hostname to be non-empty")
}
if info.IPAddress == "" {
t.Error("Expected IP address to be non-empty")
}
}
- Setup project and installer script: 30 minutes max
- Implement command execution: 45 minutes max
- Create HTTP server and endpoints: 45 minutes max
- Code Quality
- Clean, idiomatic Go code
- Basic error handling
- Functionality
- Successfully executes required commands
- Correctly returns results via HTTP
- Completeness
- All core requirements implemented
- Basic documentation provided
- Focus on core functionality first
- Clean code is important, but perfect is the enemy of done
- Document any assumptions or limitations
Be prepared to discuss:
- Your architectural decisions
- How you would scale this for a large organization
- Security considerations
- Performance optimizations
- How you'd handle offline functionality
Good luck - We're excited to see your solution!
I've completed this and my code is available here: https://github.com/ryanfaerman/agent-smith