I know of two (better) methods you could use.
If, like a fence, you think the structure will be subject to strong sideways forces from the wind trying to blow it over, you can sink a concrete spur in the ground, setting in in concrete. You can then bolt your wooden post to it, a few inches above the ground, so it will not be made damp and will not be in contact with rot spores or wood-eating insects.
If, like a shed, the load will mostly be downward forces from weight, you can cast a concrete pad into the ground, raised several inches above ground level, with a steel shoe cast or bolted into it. This will have the same effect.
For bext results soak the ends of the posts in wood preserver beforehand, and paint the steelwork all over with oxide primer and gloss paint. And position the posts under the roof structure, and inside cladding if you have it, to keep rain off.
Examples of both methods in my pic. You can make the pads neater than mine by using better wooden formwork to make the visible part, and a few inches into the ground, square with a slight camber to throw off any rain. I can't remember why I made that pad so big. Might have been a raised neighbours garden previously. The others are much neater. Mine have masonry paint on the concrete to help them blend into the fence stain on the timber. You could paint or stain yours any colour you want.
The reason mine also have a post is that I developed the shed inside a fence I had previously built. Otherwise I would have used pads because the other side is fixed to the house and will not blow away.