[noun] + の + ごとく + [verb] [noun] + の + ごとき + [noun] [noun] + の + ごとし [verb (plain)] + が + ごとく / ごとき / ごとし [verb (plain)] + かの + ごとく / ごとき [noun] + ごとき
ごとく, ごとき and ごとし mean "like", "as if". They are three forms of one literary word and do the work of modern ように, ような and ようだ: ごとく describes a verb or an adjective, ごとき describes a noun, ごとし ends the sentence. A noun takes の before them. In kanji they are ごとく如く, ごとき如き and ごとし如し, and both spellings are common.
The forms are not interchangeable. Before a noun it has to be ごとき: ×夢のごとく日々.
A verb takes が between it and ごとく – an old use of が that works like の. With かの in place of が, the comparison is counterfactual: "as if", when it isn't so.
All three belong to writing, speeches, proverbs and set phrases. In conversation the same sentence uses ように, ような or みたい, and ごとく would sound theatrical.
Straight after a noun, without の, ごとき means "the likes of", "a mere". Said of someone else it is contempt; said of yourself it is humility.