Sort xml payload in Golang - go

I have one project in aws lambda in Golang.
There we are using aws-api-gateway to accept rest api.
I wanted to sort the xml payload based on element coming from the user side.
But the problem is unmarshalling the xml payload is not allowed.
I see somewhere that I can use xslt processor to sort the xml. But I’m unable to use this go package(github.com/wamuir/go-xslt) as it requires me to install some extra packages which is not in go. And our platform-team will not allowed it.
Is there any other go package that I can use.

Related

marshal protoreflect.MessageDescriptor

I am trying, in the line of google.golang.org/grpc/reflection to marshall a protoreflect.MessageDescriptor. The idea is to have a server serving protoreflect.MessageDescriptor to a client.
The client would use the protoreflect.MessageDescriptor with dynamicpb.NewMessage to instanciate protobuf messages.
I am not able to marshal protoreflect.MessageDescriptor because it does not implement ProtoReflect(). It does not seem to be possible to marshall it and "send" it on the wire.
Anyone has tried that already? Am I trying to do something forbidden by design in the go implementation of GRPC?
I believe you want to be using DescriptorProto in your protocol, not a protoreflect.MessageDescriptor. There are conversion functions in the protodesc package like: https://pkg.go.dev/google.golang.org/protobuf/reflect/protodesc#ToDescriptorProto

Documenting a gRPC API

One can document a REST API with OpenAPI. Is there a similarly clean and standardized way of documenting gRPC APIs? E.g. specify what values an endpoint is expecting, what the return values mean, etc. The service definitions in a .proto file do not suffice as documentation.
I just found this: https://gendocu.com/
which let you try your APIs and document the fields. Also generates code for different languages. The project looks promising.

Paw: Possible to copy/paste data from Hash/Dictionary source in target language?

I'm using Paw to integrate with an API and it's a great tool, but the codebase I'm working in has lots of data in Ruby Hashes already that I would like to bring into Paw for testing. Moreover, I would like to be able to copy the data out of a Paw response for use in Ruby code rather than having to copy JSON and either store it as a String and parse it in my code or manually convert it to a native dictionary data structure. Is this possible?

De-serialization without protobu

Using protobuf I am able to serialize data. I need to send this serialzed packet to different location. As I know I need protobuf again to de-serialize the data.
Is there a way in which we can de-serialize data without using full protobuf library or maybe a minimum version of protobuf.
TIA...
Once you have generated the serialization and deserialization code you don't need the protoBuff library. The ParseFromIstream() method is all you need.
From what I've read you never actually import Protobuf, you just run it to generate code that is dropped into the project. The generated code does not require the program that generated it.

Output all language strings in Revel?

I'm developing an API Server in Go and the server (at the moment) handles all translations for clients. When an API client fetches particular data it also asks for the translations that are available for the given section.
Ideally I want to have the following folder structure:
/messages
/home.en
/home.fr
/home.sv
/news.en
/news.fr
/news.sv
Where news and home are distinct modules.
Now the question I have for Revel is is it possible to fetch ALL language strings for a given module and given locale? For example pull all home strings for en-US.
EDIT:
I would like the output (something I can return to the client) a key:value string of translations.
Any guidance would be appreciated.
It seems to me that revel uses messaged based translation (just like gettext does), so you need
the original string to get the translation. These strings are stored in Config objects,
which are themselves stored in messages of i18n.go, sorted by language.
As you can see, this mapping is not exported, so you can't access it. The best way
to fix this is to write a function for what you want (getting the config by supplying a language)
or exporting one of the existing functions and create a pull request for revel.
You may workaround this by copying the code of loadMessageFile or by forking your version
of revel and exporting loadMessageFile or parseMessagesFile. This also is a great opportunity
to create a pull request.
Note that the localizations are stored in a INI file format parsed by robfig/config,
so manually parsing is also an option (although not recommended).

Resources