Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

360
Views
Golang: Is it safe to say that if a struct implements a method then it satisfies all interfaces that define that method's signature?

In the docker source repo, there exists an interface in image/backend.go:

type imageBackend interface {
    ....
    ImagesPrune(pruneFilters filters.Args) (*types.ImagesPruneReport, error)
}

and, there is an implementation in daemon/prune.go:

func (daemon *Daemon) ImagesPrune(pruneFilters filters.Args) (*types.ImagesPruneReport, error) {
    ... implementation details ...
}

Does this mean it's correct to say that Daemon implements the imageBackend interface?

Background: I'm trying to understand how calling docker system prune cmd invokes the ImagesPrune function in daemon.go. I could trace the code flow as:

cli/../system/prune.go -> cli/../prune/prune.go -> cli/../image/prune.go -> client/image_prune.go -> api/server/..image/image_routes.go -> api/server/../image/backend.go -----> ??? ----> daemon/prune.go

I don't know what comes in the ??? section above.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Yes, Daemon does implement the imageBackend interface (as pointed out in the comments, it's actually the *Daemon type that implements the interface). All of imageBackend's methods are implemented in various source code files inside the daemon package (mostly the image_*.go ones).

In the image_routes.go the postImagesPrune method is called, which in turn calls the ImagesPrune method of s.backend. s is a pointer to the instance of imageRouter.

type imageRouter struct {
    backend Backend
    decoder httputils.ContainerDecoder
    routes  []router.Route
}

This imageRouter instance is initialized with backend set to an instance of Daemon in cmd/dockerd/daemon.go here.

So when s.backend.ImagesPrune is called, it is running the ImagesPrune method of the Docker Daemon, which as you point out above is in daemon/prune.go.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!