Thinly slice the onion and finely chop the garlic.
Heat the olive oil in a frying pan, add the onion and gently cook it under cover, over a low heat until softened (stir regularly), for about 15 minutes. Add the garlic after ten minutes of cooking.
Meanwhile cook the spaghetti according to the instructions on the packaging, drain and keep warm in the pan (just put a lid on).
Using a Julienne peeler or a spiral slicer cut the courgette into ling, thin strips.
When the onion is soft add the chilli, vinegar and sugar. Let it bubble, then cook for 3-5 minutes until the onion is slightly caramelised. Stir in the courgetti, put a lid on and cook for a couple of minutes, then turn off the heat and let it steam for 3 minutes.
Add the spaghetti to the onion and courgetti mixture then crumble the goats cheese on top and toss gently. Season to taste.
Serve immediately.