Every person, company, or corporation having the control or management of any railroad shall, outside of any corporate city or town, and outside the limits of any sidetrack or switch, cause to be constructed and maintained in good repair on each side of said railroad, along the line of said right-of-way of such person, company, or corporation operating the same, a substantial fence, and at every point where any roadway or other public highway shall cross said railroad, a safe and sufficient crossing must be built and maintained, and on each side of such crossing and at each end of such sidetrack or switch, outside of any incorporated city or town, a sufficient cattle guard: PROVIDED, That any person holding land on both sides of said right-of-way shall have the right to put in gates for his or her own use at such places as may be convenient.