the go-native embed?
https://github.com/ansible-semaphore/semaphore/issues/1015#issuecomment-1657194811
It's a handful of lines in the codebase, but I have no clue how to rewrite it as I do not usually work with golang.
learn and do it yourself
you can use embed in two ways: - embed dir as filesystem - embed file as string or []byte variable
https://github.com/ansible-semaphore/semaphore/blob/85d9936082bc8a3fc763ff8d3f1f6a6695bfc956/db/sql/migration.go#L38 this looks like it requires the first approach
here's how to use embed.FS
I've ran into a bit of a snag. /api/router.go embeds ../web/dist and embed does not support accessing parent. I've seen this resolved by putting the embeds in a higher go file, but there isn't one, what's the proper solution here? A) Reorganizing the directory structure (author probably won't like this and it will require a lot of reorganizing) B) Creating /embed.go and putting embeds there C) Something else entirely
How many embedded files are there? If there aren't many I would simply use variable embedding
Ah, it's an embedded web frontend, I see Then variables are not an option.
Variant B would be using the variables approach in embed.go?
it would be using /embed.go to embed web/dist as then there will be no need to access a higher directory structure, though I am not sure how exactly to implement it.
I am not sure if that's a valid approach, tried using the same api package for the include, but apparently then it should be in the same directory as the other api files. Tried creating another new package, but I failed at all attempts to import it.
Обсуждают сегодня