I probably borrowed this from somewhere, but darned if I remember where:
(defun goto-line-with-feedback ()
"Show line numbers temporarily, while prompting for the line number input."
(defvar goto/line 0)
(setq goto/line (read-number "Goto line: "))
(forward-line (1- goto/line)))
M-g to that; works a treat.
(Note that if you're using Emacs 26, you should use
display-line-numbers-mode instead of
linum-mode -- just swapping the two function calls is all you need to do.)
As a general rule — to try to address your question in a more generic, "teach you to fish" kind of way — any function of the form
foo-mode in Emacs will take a positive argument to unconditionally enable the mode, and a negative (or sometimes
nil) argument to unconditionally disable it. The best way to validate that is to read the documentation for the function (
C-h f then the function name).