GithubHelp home page GithubHelp logo

Comments (3)

ti-mo avatar ti-mo commented on September 22, 2024 2

internal.Identifier() is used to generate internal/sys/types.go and is responsible for e.g.

type Cmd uint32

const (
	BPF_MAP_CREATE                  Cmd = 0
	BPF_MAP_LOOKUP_ELEM             Cmd = 1
	...
)

This might be stating the obvious, but all-uppercase enum keys like FOO_BAR are widely used in the kernel and C projects in general as globally-unique values that make grepping large codebases possible. Sharing these identifiers between Go and C is desirable, so we're not going to change this behaviour by default. The convention is to stick to CamelCase, but this is still just a convention, not a requirement by spec. We're better off breaking the convention to keep things recognizable here.

It's common to create Go-friendly aliases for frequently-used enums whose names are too long (const LookupAndDelete = BPF_MAP_LOOKUP_AND_DELETE_ELEM).

I get the tendency to want to change this, but I'm not convinced it's worth the additional complexity. As I've mentioned, these enums are uppercased for visibility/uniqueness, and it's often better to preserve them to keep things clear and consistent. If this is not required, why not modify the enum on the C side to be lowercased?

from ebpf.

MarcusWichelmann avatar MarcusWichelmann commented on September 22, 2024

Ah, thank you for clarifying the reasons why it's currently done like that. Good point with the aliases. We'll probably go this route then.

from ebpf.

ti-mo avatar ti-mo commented on September 22, 2024

Great, thanks for the reply! Closing this.

from ebpf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.