Skip to content

How can i ignore code generation for a particular field only ? #49

Open

Description

@ymolists

Thank you so much for writing this utility !

I have a field in my struct that is transient. Meaning it gets generated from random values. I don't want to use that field for equality. Is there a way i can force code generation to ignore a certain field in a struct ? ala autogold:"omitfield"

Best Regards

Activity

  1. emidoots commented on Sep 1, 2023

    @emidoots
    Member

    It's not supported, sorry. The way to do this is to convert your struct into a new struct type or Go value like map[string]any that doesn't contain that field. Then you can pass that value into autogold.

    You can also add a String formatter to your Go struct, and then pass that string to autogold instead

  2. ymolists commented on Sep 6, 2023

    @ymolists
    Author

    Thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions