I have been out of programming for the past decade. I recently stumbled across Go and this is the first language I have seen in this past decade that has caught my interest as I think it shows the ability to create a program that can . I like how it produces a compiled program that I believe is suppose to be able to run on different platforms, it is "c like", designed to take advantage of multi core processors, and I believe also distributed web apps.The first "problem" I encountered is that Go does not have a user interface. I can grasp how to create a go program to perform a task, but what caused me some conceptual problems is the gap of how to know when to perform the task and what to do with the result.So I kept reading and looking into this issue, and I believe the answer for me is HTML5/CSS3. Html allows for the typical user input items (text box, check box, list, button). And after looking at the new features in html5, such as the canvas and flexbox, as well as go's ability to work with an html template, and that provides the way to show the result. So this gives me a constructive direction to work with.Now we get to some practical issues, which is where the questions arise as I still have some things that I have not figured out yet.#1. Executable file.I have myapp.go which performs a simple task. It is compiled into myapp.exe.I am using Win7 on my pc with eclipse for the IDE. Can I take the myapp.exe and run it on a mac and/or linux pc? What about an apache web server?This is the first test to get my eventual end program to be usable on different platforms. I want to run it on an apache server to prepare the web site pages. I also want a "desktop" program that will do most of the processing so the server is not over used. (see #2 for reason of this.)1B) From what I understand, at this time myapp.exe will not run on Android. So for a droid app, I would just wrap the html5 so the app could be downloaded from the google play app-store.Is it planned to have a go program be able to run on droid?What about the chrome os?------#2. Getting the "myapp" to run on the apache web server.I am using a hosted web site on a shared server.A) What do I need to do to get the myapp.exe to run on the web server?Can I load it to the root directory of the web site, or even put it in a sub directory?B) The examples I have looked at use http.ListenAndServe("localhost:9999", nil) this won't work for the actual web site. What should this be set to?-----#3. Running on the desktop.Because of the shared server that has limits on the use, I want to offload some of the processing to the desktop. I can do this for both preparing the pages, and also for some computations. The myapp would run on the desktop, pull data from the website, and then display the result in the browser that is set to work with "localhost".As mentioned, I have used the localhost to get the myapp to work with a browser. But I would like to integrate this a bit more. I would like to have a shortcut that runs the myapp.exe file, and have it open the browser with the browser directed to "localhost".Am I correct that this can be done using the os/exec package? (using cmd.start)3B) What is the best way to end the myapp program when the browser is closed?-----#4. Desktop version updating.I realized that if the os/exec package can be used to start another program, then I can create a "launcher" program.The "launcher.exe" would be downloaded from the server and placed in a directory on the pc.The "launcher.exe" program would be the one that has a shortcut set to it. When ran it would check the website for the latest version of the myapp program, if needed download it from the website, and put it in the correct directory on the pc.Then the launcher.exe would start myapp.exe.Am I on the right track with this line of thought?----The answers to these questions should tie up the loose ends where I will have a better grasp on the concepts and can get to work on the details.Thanks,Jim.
Jim.--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/8VjyHRYMl2Q/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/8VjyHRYMl2Q/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/8VjyHRYMl2Q/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
And this is where I think that go is failing to get widespread support.For those that are low level developers, that know "systems" type of issues, which quite often include the network admin type of issues, it is not a big deal and they can make go work.But for those of us that are not at that level, these problems with getting go to work on a web site is a major stumbling block. And if it is too complicated it winds up where a person will just pass up on go and use a different language that they can get to work on the web site.Consider this. With php all I need to do is use an ide, whether it is notepad or one that has features built into it. I create a text file with the php tags, the code to "do stuff", give it a php extension, ftp it to the web site, and it runs!Basically all I have to do is learn the correct php syntax. This makes it a pretty low barrier to overcome!For go, you have to learn the syntax, which is not that big of a deal. The development of go has made this something that is not a major obstacle.There is a bit of an issue on the compiling to run on the different platforms. Such as to do a localhost test I would compile to windows. When it is ready for my website, then I need to compile it to run on linux.Then there is the barrier that has been my major problem, what to do to get it where when I type in the website address in a browser, the go program will work.
Matt,
The comparison to php was a bit of a crude one. I would not be here trying to learn this if I did not think that go could do a lot more than php.Actually, this is the first time in a very long time that I have been excited about a language, as I can see a lot of potential for using go where in the end it will save me a lot of work and be usable across many different platforms in one form or another.
BTW, yes, the compile to each platform is something that will have to be done, which is a cost of it being a compiled program, a cost that IMHO is well worth it. I listed it because it is just another step that has some details that have to be paid attention to so it is done right.
And yes, you are right, I am behind the times in regards to modern dev environments. I have been away from programming for a while, a big part of it has been due to my impression that there was not a language that would do what I wanted to do. The "juice was not worth the squeeze".Once again, this shows that I see a lot of potential for go.
>"start building an application first"
I have. :)I am taking it in measured steps. I found how easy it is to use the start of the program on my desktop with localhost. So the next step was to put it on the website and see it run there. Thus, this thread......
For the next few days I am going to break this down to 2 steps. First I need to get the program compiled to run on the linux server.Then I need to digest all of the information I have gathered and start "playing" with the program on the linux box.It looks like I will have to do a lot of trial and error to figure out what will work. (From everything I have seen, it appears to me that the program will be ran in the background on the linux box.)
>"What's serving on localhost:8080 for example, is actually a web app."I understand that part of it. My pc is acting like a server to have the program interact with the browser.
>"You can deploy it on mysite.com:80 and it will be accessible to the world as
http://www.mysite.com."
Will this cause a conflict between the go program and apache?(this was one of the things I figured would be part of the "trial and error".)
>"Yes, Go has a higher barrier to entry than PHP, for more power and
flexibility. But it's not any higher than something like Ruby on Rails
for example. "
I think it is higher than ruby on rails. With one little search I found several links to "how to's" that contain instructions on what a person needs to do to get ruby on their apache server.(from that very quick glance, it appears that the instructions I found install the runtime on apache, and then when you write the app it is handled in a manner similar to php)
>"Good luck with your guide! "Thanks. As you can see in this thread, a lot has been said, but there have not been any clear instructions so I am left with a lot of trial and error.I am hoping that once I am done with this, it will make for a good wiki entry on the steps needed to be followed.
Also, take a look at various PaaS/cloud options like Google App Engine. I personally dislike PaaS' because I have to learn the specifics of their API and I like root control of my OS. But I'm *guessing* that they will minimize your job of daemonizing and monitoring your running app.
I went to mysite.com:8080 and the page shows up. So it is running on the web site and is viewable! yeah! :)BUT, here is the problem. It is a shared server. So a person with a different url on that server can also see the program. othersite.com:8080 showed the same hello page. This is a problem, I can not have my program show up on other web sites!I then made the next change to the listenandserve command to ("http://mysite.com:8080", nil)It compiled to linux32, I ftp'd it to the server, and when I ssh'd in to run it, I got the error message of "too many colons http://mysite.com:8080"It would not run!
James,Thanks for the answer. I have some followup questions to it.If listenandserve is looking for an IP address, why are there examples that show using http://url.com ?(note: that is just a question out of frustration of trying to follow an example that sends you down a wrong path)
I will take a look at the servemux. Would you happen to know of an example where it is used, so that I would make sure I use it correctly?
What is a reverse proxy? Your last part of the answer is confusing, as you say here is what you need to do (servemux), but don't do it as "it will complicate things and you can handle the virtual host definitions in the frontend server". How would this be handled in the frontend server, and would this be better than doing the servemux?
package main
import (
"log"
"net/http"
"os"
)
const resp = `<html>
<head>
<title>Simple Web App</title>
</head>
<body>
<h1>Simple Web App</h1>
<p>Hello Jim!</p>
</body>
</html>`
func handler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(resp))
}
func stopHandler(w http.ResponseWriter, r *http.Request) {
go gopanic()
}
func gopanic() { // very ugly way to abort the listenandserve
panic("stop request called")
}
func main() {
http.HandleFunc("/", handler)
http.HandleFunc("/stop", stopHandler)
err := http.ListenAndServe(":8080", nil)
if err != nil {
log.Println(err)
os.Exit(1)
}
}
When I run that code, it does run on the web site, and the /stop will cause it to panic and end the program.
The "problem" is that this also shows up on other web sites that are on the same server!
And the /stop on the othersite.com will cause the program to panic and stop.
So I need to make this where it responds only to my web site. And as someone above said, I do NOT have a specific ip address for the web site. It is an ip to the server. I believe apache takes over at that point to send the request to the correct url.
Because it is a shared host, I don't know if I can do any of the reverse proxy stuff or anything else that would effect the other sites on the server.
In another thread it was suggested to use localhost:8080 in the handlefunc. Further discussion suggested it might need :// infront of that.
I tried this change to the above code.
http.HandleFunc("localhost:8080/", handler)http.HandleFunc("localhost:8080/stop", stopHandler)err := http.ListenAndServe(":8080", nil)
the program ran, but it gave a 404 page not found error when I went to mysite.com:8080
same thing when I tried the /stop at the end of the url.
The same thing happened when I went to the url of another site on the server, so it is not responding only to my domain.
How do I get the server to only respond to requests for mysite.com? Please give specific code examples, I have not been able to figure it out on my own.
Thank you,
Jim.