i want know if there`s a way to read a go and get the content from that file using go.
for example: I have a file called car.go and inside this file has a struct called Car, i want to read that struct Car properties.
i want know if there`s a way to read a go and get the content from that file using go.
for example: I have a file called car.go and inside this file has a struct called Car, i want to read that struct Car properties.
Not sure whether I am getting it right, but if you are trying to use struct that is defined in other file, then you can import the struct in your current file.
Note - If both the files are inside a comman module, then you don't need to import, you can directly use all structs condition that their first letter is capital.
Refer this for better understanding of import - link
In case you want to read file of any extensions, you can refer this thread - Link
Hope this helps you!
You can parse go files with a go package. Take a look at this example: https://pkg.go.dev/go/ast#example-CommentMap