Defect formation and magnetic properties of Co-doped GaN crystal and nanowire