Skip to content
← Back to Community
How can i ping my repl that is written in GO.
Profile icon
badsport

The title say it all.
Thanks in advance

Voters
Profile icon
kznnow
Profile icon
badsport
Comments
hotnewtop
Profile icon
Coder100

Hi! Seeing from past comments, here's a step-by-step tutorial of what is needed.

Step 1: Server

Super simple, add this to your code:

// packages needed import ( "fmt" "net/http" ) func keep_alive() { // APPEND this to your code, do not replace it. http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Welcome to new server!") }) http.ListenAndServe(":5050", nil) } // Now, in your main file: func main() { // ... your code ... keep_alive() }

Step 2: Ping

uptimerobot works, https://ping.matdoes.dev is what I use, https://keeper-upper.turbio.repl.co is the official repl.it service. Use whatever you like!

Profile icon
badsport

@Coder100 thnak you 1 million times ill try it out

Profile icon
Coder100
Profile icon
badsport

@Coder100 i did it and ran it but i have this error:

main

./main.go:21:1: syntax error: non-declaration statement outside function body
./main.go:74:6: main redeclared in this block
previous declaration at ./main.go:17:6
compiler exit status 2

Profile icon
CodingCactus

so your repl in go is running a web server and you want to ping it? just ping the repl-name.badsport.repl.co link

Profile icon
badsport

@CodingCactus no need for a new file?

Profile icon
CodingCactus

@badsport why would you need a new file to ping something? You have the webserver set up? just ping it

Profile icon
badsport

@CodingCactus okay ill try it out

Profile icon
badsport

@CodingCactus i dont have a webserver set. im new to go

Profile icon
CodingCactus

@badsport well why are you trying to ping something if you don't have a webserver to ping?

Profile icon
badsport

@CodingCactus i have a file that i want to ping. i know how to make a webserver in py but not go. could you explain it to me?

Profile icon
CodingCactus

@badsport you aren't supposed to ping a specific file, you are supposed to ping the web server that is made by that file

Profile icon
badsport

@CodingCactus well my file doesnt have a webserver with it

Profile icon
CodingCactus

@badsport yes because you are supposed to code one in that file

Profile icon
badsport
Profile icon
ironblockhd
Profile icon
badsport

@ironblockhd okay ill try it out

Profile icon
PattanAhmed

@badsport Hi,
Where to ping?
You mean fork or something else?
Please comment me below!
Thanks!

Profile icon
badsport

@PattanAhmed Like uptimerobot as an example

Profile icon
PattanAhmed

@badsport Please tell original one:-
Please don't say like
I want to get the idea.
Thanks!!

Profile icon
badsport

@PattanAhmed if uptime robot would work that would be great

Profile icon
PattanAhmed

@badsport Oh got it...
Check this amazing website...
Enter an URL there of your Repl and click Go
Done!
Click here

Hope this helps

Profile icon
badsport

@PattanAhmed okay thanks for the help and the quick response
https://repl.it/@badsport/... that url?

Profile icon
PattanAhmed

@badsport Nope!
Paste your Repl URL
Not home page
Thanks!

Profile icon
badsport

@PattanAhmed ah i see so the url that is above the terminal?
https://....badsport.repl.run something like this?

Profile icon
PattanAhmed

@badsport No!
Your Repl URL like this as an example:-
https://repl.it/@badsport/bramssniper3
Thanks!

Profile icon
badsport

@PattanAhmed thank you you have been a massive help. if it pings can i turn off my machine and the repl will still be running/online?

Profile icon
PattanAhmed

@badsport Welcome
Happy to help
Hope that helps
Please mark my answer if that helps

Profile icon
badsport

@PattanAhmed thank you but i didnt get it to work

Profile icon
PattanAhmed

@badsport You mean you don't understand?
Thanks!

Profile icon
badsport

@PattanAhmed no sorry im still getting some errors . im soory for not understanding because im new to Go

Profile icon
PattanAhmed

@badsport Yes, it will...
It will keep running your Repl even if you close it...
Thanks!

Profile icon
PattanAhmed

@badsport Solve your issues in the code
And Try!
Anyways, Use that website...
If you want to ping...
https://ping.mat1.repl.co/
Thanks!

Hope this helps
Please mark my answer if this helps