help for add code

hello. i have created development setup and for that i am sending my device id over URL so i have write that code in cmd/syncthing/main.go file. then compile it. and before my code i have print static text for test bit not print on console .

so not getting idea what is wrong with compile. i have doubt my code that part is not executing or not compiled in binary.

so any developer can help me ?


Below is mine custom code and i want to add when syncthing app open that time generated device id iam sending on my server. so i have added that code in main() function in cmd/syncthing/main.go file but that is not working.

package main

import ( “fmt” “strings” “net/http” “io/ioutil” )

func main() {

url := ""

payload := strings.NewReader("{\"deviceid\":\"12332-23213-sadsaddsasd-asdsad-123213\"}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json")
req.Header.Add("cache-control", "no-cache")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)



I think you may be looking for general Go programming help. is one place for that, the go-nuts mailing list is another. My first tip is to not ignore the error handling, it’s important. Also, when asking for help, explain what problem you are having, including any error messages or similar.

1 Like

i have created separate file of my above code and it is working fine.

and i have also added in cmd/syncthing/main.go file and then i have did go run build.go build

then from syncthing folder i have run that syncthing file but my code is not executed

I’m not sure how to advice you on that. Apply regular troubleshooting until the issue becomes clear, I guess.

ok…can u please give me your skype id . i will share u mine screen or Team viewer.

No :smiley:


Seriously, this is not a place to ask generic help on how to use Go, as this is nothing related to syncthing, it’s mostly you not knowing how to use Go. @calmh has given you a link where you can ask generic go help.