Here is an example of what you are talking about, i think?
https://en.wikipedia.org/wiki/M982_Excalibur
looking it up,
https://en.wikipedia.org/wiki/Orders_of_magnitude_(acceleration) suggests that our current tech allows electronics to survive;
152 210 m/s2 15 500
g Rating of electronics built into military artillery shells
[26]
a slug acelerated at that gee force, across the length of a typical naval gun barrel, would hit a final speed of, um, yeah the exact formula escape me.
Thankfully I can google it, and muzzle velocity of artilery shell is 770m/s. Which in space would be pathetically slow. So we would need to provide same accelleration across a much larger barrel or longer time with a railgun, maybe, dunno. Most likely modern electronics would not survive being accelerated to 30,000,000m/s (10% speed of light) no matter how long your rail gun barrel is,
Remember that if your accel is 152,000 m/s2, and you apply that force for a full 0.1 seconds, then in 0.1 seconds, that shell already crossed 7500 meters, which would be pretty tough to fit in a warship, and would still only be traveling 15,200 meters per second, or about 1/20,000th the speed of light.