Heat a large skillet over medium-high heat and add the olive oil. When heated through, stir in the onions and cook, stirring frequently, for 10 minutes.
Reduce the heat to medium-low and add the salt, sugar, and vinegar. Cook for about 30 minutes, stirring every 4-5 minutes, or until the onions are a deep, dark brown and taste sweet and soft. If you are going to leave the onions to caramelize while you do other things, leave a splash of water in the pan so they don't burn. Leave to cool for at least 10 minutes.
Meanwhile, heat the oven to 325°F (160°C). Spread the baguette slices on a baking tray and bake for 6-8 minutes or until lightly toasted.
To prepare the pintxos, top each slice of bread with a heaped teaspoon of onion and a heaped teaspoon or large slice (depending on the type) of goat cheese. Garnish with a few rosemary leaves and serve at room temperature.