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.
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.
--
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Eric, you summed it up real well. The thing is I need the go code to get it to work.
Thanks
Jim.
http/1.1 protocol supports virtual hosts. I have no idea if go supports 1.1. But I doubt it as it I am assuming it is meant to be lower level.
I am at my grandsons ball game. I checked your links on my DROID and they worked as intended. The start&stop commands worked too on the first link.
The second link returned a 404 like it is suppose to and the start&stop commands also returned 404.
So it looks like that should do the job.
In the morning I will lead that code on my server and let you know the results.
Thank you! !!
Jim.
When "listenandserve" is called, it is telling the operating system to send internet requests to the go program. For the ":8080" we are specifying to limit those requests to only the ones that are coming in on port 8080. In this case it uses all requests that the operating system gets on either "localhost" or the ip address that maps to localhost.
This explains the behavior I was getting when I first got the program to run on the web site, where mysite.com:8080 andtheirsite.com:8080 both got the "hello" page.
************It seems to me that the net/http routines are missing the way to define the domain name, so that when listenandserve is called it can not only filter on the port number, but also on the domain name.***********
As to Matt's suggestion to redirect the root domain name to www.domain name, I must not be too bright, cuz I have not figured it out. Or at least now how to do it by adding or modifying a line in the code that ksug posted.I just am not getting the grasp on how to get it done.
So, I am just going to use the gorilla mux routine, as they have a register domain feature, and then the way to call the declarations for the additional path.(Perhaps this is why I did not figure it out. I was not looking at doing a separate package that manipulates the servemux and handlefunc processes)
James,ok, I was wrong with the fine details, I had it backwards as to the ip/localhost mapping. I believe though on the "concept" we are both saying the same thing. "The operating system knows nothing about the hostname intended for the incoming packets"Because the go program is listening to the port, and the operating system does not know anything about hostnames, the go program is showing up on any/every domain on the server that makes a call to that port.
"Checking the host header on every request isn't needed in most situations,"On a SHARED server, where there are multiple domains, this becomes an issue and is needed because the operating system does not know about host names. The program needs a way to "filter" where only the correct domain name can access the program.Concerning the redirect, you said "These things are easily configured in a webserver with no extra code, which is another reason you may want to drop one in front of your application. You then don't have to worry about the virtual host, and the handful of redirects or rewrites you may want."Are you talking about doing a linux or apache redirect?
I was trying to figure it out using the go redirect in the net/http package.
And it would appear that it would take a bit of extra code to do it in go, which is what the gorilla mux has done. It is a good bit of code.From a "casual programmer" perspective, perhaps the hostname should be a feature in the standard library.If/when go becomes more popular and starts being used by "the masses", many of them will want to just rent a website from a webhost and put their web site up. So the issues I am encountering will be pretty widespread, as I believe that linux + apache is one of the more common hosting platforms, and many people will opt for the lower cost of a shared host.So being able to put the host/domain name into the listenandserve command for the filtering would make it a lot easier to use.
....
************It seems to me that the net/http routines are missing the way to define the domain name, so that when listenandserve is called it can not only filter on the port number, but also on the domain name.***********
IMHO it would make life a lot easier if the listenandserve routine would allow for the registration of the domain name in a simple manner. Then the handlefunc command would work just fine for the "/start" type of declarations for additional path of the url.
As to Matt's suggestion to redirect the root domain name to www.domain name, I must not be too bright, cuz I have not figured it out. Or at least now how to do it by adding or modifying a line in the code that ksug posted.I just am not getting the grasp on how to get it done.
So, I am just going to use the gorilla mux routine, as they have a register domain feature, and then the way to call the declarations for the additional path.(Perhaps this is why I did not figure it out. I was not looking at doing a separate package that manipulates the servemux and handlefunc processes)
Perhaps after some time of looking at the gorilla code I will get it figured out..........
Jim.
************It seems to me that the net/http routines are missing the way to define the domain name, so that when listenandserve is called it can not only filter on the port number, but also on the domain name.***********
Jim.--
Thanks all,
@Andrew,A big Thank You for the links to the video and the webfront example.You are good in those videos, I was following along and it makes a lot of sense.
I believe I had already seen that video once a month ago when I first started looking at go. I did not think to make note about the example that was used in it.I believe that the issue of sites on shared hosts will be an issue that will show up more and more as go gains users. So I trust that you don't mind that I will include those links in the guide that I am working on to show the steps that I have used to get a go program developed on a win7 pc, cross compiled and ran on a unix/apache server.
8. Log into the server. Make sure your login has admin privliges.cd /var/www/html (this is the path for my server. Some servers could use just /var/www)./program_name &
I definitely have server permission issues. I put just the "forward" line in the json file to activate the reverse proxy.
I was told permission denied to do the redirect from port 80. So I tried it where the incoming port was 1234 and the redirect was to 8080. The connection was refused by the server.
Jim.
On Fri, Jun 14, 2013 at 9:43 AM, Jim Ellis <jimel...@gmail.com> wrote:
I definitely have server permission issues. I put just the "forward" line in the json file to activate the reverse proxy.
I was told permission denied to do the redirect from port 80. So I tried it where the incoming port was 1234 and the redirect was to 8080. The connection was refused by the server.Only root can listen on port 80. The usual solution to this is to listen as root and then drop privs to whatever user (e.g. apache, nobody, etc) afterward.
I definitely have server permission issues. I put just the "forward" line in the json file to activate the reverse proxy.
I was told permission denied to do the redirect from port 80. So I tried it where the incoming port was 1234 and the redirect was to 8080. The connection was refused by the server.
So, unless I figure out what config files need to be edited on the apache server, and what the change is that would be needed, I have to use the listenandserve with :8080 in it. I can "live" with this for development. To go the web site a "real" one though either I will need to get that apache server configured to allow the redirect from port 80 to 8080, or I will need to go to a different host. So while I am doing the development I will be looking into both options and make a decision that is best for me at that time.
@James,"I you have access to the apache config, you would be better served by proxying your domain from port 80 to 8080, rather than setting up a redirect. If you add any html pages, the browsers are always going to assume the incorrect port if you don't specify it directly."It is clear in this thread that I lack a lot of knowledge about network systems admin. So, I want to make sure I understand what you are saying, also I believe it ties in with Ksug's reply.I take it that it would be best to let apache listen to port 80 and when a request comes in for "mysite.com" send it to port 8080.My go program will be listening to port 8080 and will then process the incoming request. If it matches a handle I have set up in the program, then the go program will return the "page" results. If it is not a handle I have set up is an issue I have learned about yet. I "guess" that there are 2 possibilities for this.#1. the request "passes through" and if there is an html page the apache server returns it to the users web browser.#2. I will need to put some code into my program that if the requested url/path is not one of my handles, to check for the specific html page (or an index.html page) and return it as the result.
"That directory is probably in what apache calls the DocumentRoot. Do no put your executable there, as it will be accessible from the web, and could lead to other problems if the server is misconfigured, or you just don't want anyone to get the raw executable. Put it somewhere outside the view of the webserver."That pertains to #6 of the guide.I had asked about this earlier in the thread, and the answers were more of a "you can" than "this would be best".I appreciate you giving me a "this would be best" answer with the explanation of why.I will change step 6 to use /var/goprg as an example path.I believe a note would be needed that in the go program the path will need to be paid attention to when it comes to uploading and downloading files via the browser."Simply backgrounding a process is the worst way to run a service, if it even continues to run when the shel exits (it would have to ignore SIGHUP to do so). For testing you can run it in something like screen or tmux, but you would want something to manage the process eventually."Yes, as a "permanent" web site I agree with you. For the stage I am at right now, the backgrounding is a good way to run it for testing as it is in development.On the server I am using I can exit the ssh client and the go program will continue to run.Your comment would be a good one to add because it sounds like on some servers that the program would be closed when the ssh client is exited.
The guy from the host I am using said that when I am ready to have the program run full time to add the command to the rc.local file so it will be started on the server boot up.
@James,"I you have access to the apache config, you would be better served by proxying your domain from port 80 to 8080, rather than setting up a redirect. If you add any html pages, the browsers are always going to assume the incorrect port if you don't specify it directly."It is clear in this thread that I lack a lot of knowledge about network systems admin. So, I want to make sure I understand what you are saying, also I believe it ties in with Ksug's reply.I take it that it would be best to let apache listen to port 80 and when a request comes in for "mysite.com" send it to port 8080.My go program will be listening to port 8080 and will then process the incoming request. If it matches a handle I have set up in the program, then the go program will return the "page" results. If it is not a handle I have set up is an issue I have learned about yet. I "guess" that there are 2 possibilities for this.#1. the request "passes through" and if there is an html page the apache server returns it to the users web browser.
#2. I will need to put some code into my program that if the requested url/path is not one of my handles, to check for the specific html page (or an index.html page) and return it as the result.
"That directory is probably in what apache calls the DocumentRoot. Do no put your executable there, as it will be accessible from the web, and could lead to other problems if the server is misconfigured, or you just don't want anyone to get the raw executable. Put it somewhere outside the view of the webserver."That pertains to #6 of the guide.I had asked about this earlier in the thread, and the answers were more of a "you can" than "this would be best".I appreciate you giving me a "this would be best" answer with the explanation of why.I will change step 6 to use /var/goprg as an example path.I believe a note would be needed that in the go program the path will need to be paid attention to when it comes to uploading and downloading files via the browser."Simply backgrounding a process is the worst way to run a service, if it even continues to run when the shel exits (it would have to ignore SIGHUP to do so). For testing you can run it in something like screen or tmux, but you would want something to manage the process eventually."Yes, as a "permanent" web site I agree with you. For the stage I am at right now, the backgrounding is a good way to run it for testing as it is in development.On the server I am using I can exit the ssh client and the go program will continue to run.Your comment would be a good one to add because it sounds like on some servers that the program would be closed when the ssh client is exited.The guy from the host I am using said that when I am ready to have the program run full time to add the command to the rc.local file so it will be started on the server boot up.------------------------------------------------------@Kyle,I "think" that my comments to the reply from James also apply to your reply.-----------------------------------------------------@ksug,Thanks for the reply and info about port 80. I remember that there is a thread in this group on hosts, and I will add your link to that list.About learning sysadmin. One issue I would face is that during the day I need to have a windows program running at all times for my work. So I would have to see if that vmware player would run in a window without interfering with my work stuff.One question this brings up about switching to a different server. Why not switch to a windows server?Since I am developing on a win7 pc, I would not have a cross compile issue, I would just compile to run on a win64, and once the server ports are configured to work with the go program, I would not need to worry about sysadmin issues.Why would using a linux or ngnx server be better?
--
On Fri, Jun 14, 2013 at 9:43 AM, Jim Ellis <jimel...@gmail.com> wrote:
I definitely have server permission issues. I put just the "forward" line in the json file to activate the reverse proxy.
I was told permission denied to do the redirect from port 80. So I tried it where the incoming port was 1234 and the redirect was to 8080. The connection was refused by the server.Only root can listen on port 80. The usual solution to this is to listen as root and then drop privs to whatever user (e.g. apache, nobody, etc) afterward.