7
votes
Fortnightly Programming Q&A Thread
General Programming Q&A thread! Ask any questions about programming, answer the questions of other users, or post suggestions for future threads.
Don't forget to format your code using the triple backticks or tildes:
Here is my schema:
```sql
CREATE TABLE article_to_warehouse (
article_id INTEGER
, warehouse_id INTEGER
)
;
```
How do I add a `UNIQUE` constraint?
I'm making a server in Go for my new page. Something simple.
There will be three sections. Index, blog and resume. Here is the code:
I want the site to have two languages. Portuguese and English.
So the urls would be /en/blog /en/resume /en/ for english and without /en for portuguese.
It's just a matter of creating three more functions and doing:
or is there a better way?
And those functions "index", "blog" and "resume" are too similar, it just changes one word. Is there a better way of coding this?
It depends on how much you want to abstract the translations away.
An easier way to do this for a simpler application would be to use a query parameter like
lang( yoursite.com/blog?lang=en or yoursite.com/blog)Your hanndler function can parse for the
langquery param, and default to Portuguese (if not present).If you want to have to define the language as part of your routes, then I would suggest using something like chi, which would let you define your route like
Slightly off-topic, This is also a good post that lets you incorporate some internationalization in your pages (similar to res/values/strings.xml in an Android application) using the
messageandlanguagepackages.