Why is the principle stating that "interfaces should belong to the package that uses values of the interface type, not the package that implements those values" sometimes violated?

This page summarizes the projects mentioned and recommended in the original post on /r/golang

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • etcd

    Distributed reliable key-value store for the most critical data of a distributed system

  • While exploring popular projects such as etcd and especially traefik, I noticed a violation of the principle that states "interfaces should belong to the package that uses values of the interface type, not the package that implements those values." For example, Here we can see that ManagerFactory import Registry interface that placed here and implementations of this interface in the same package, which violates the aforementioned principle. Even if the interface is simply a specification, it should still be defined on the consumer side. Is it considered bad practice to follow what traefik does in this case or I doesn't understand somthing? P.S. I'm newcomer, so sorry if it's silly question.

  • traefik

    The Cloud Native Application Proxy

  • While exploring popular projects such as etcd and especially traefik, I noticed a violation of the principle that states "interfaces should belong to the package that uses values of the interface type, not the package that implements those values." For example, Here we can see that ManagerFactory import Registry interface that placed here and implementations of this interface in the same package, which violates the aforementioned principle. Even if the interface is simply a specification, it should still be defined on the consumer side. Is it considered bad practice to follow what traefik does in this case or I doesn't understand somthing? P.S. I'm newcomer, so sorry if it's silly question.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts