Compare commits
2 Commits
master
...
20171019_U
Author | SHA1 | Date |
---|---|---|
|
c02269506c | 5 years ago |
|
e8c1c1e43a | 5 years ago |
22 changed files with 282 additions and 73 deletions
Binary file not shown.
@ -1,6 +1,11 @@ |
|||
/* |
|||
Landesamt für Geoinformation und Landentwicklung, Referat 35 |
|||
Einführung in die Sprache Go, 25.7.2017 |
|||
Universität Stuttgart, Digital Humanities |
|||
Seminar Nummer 582170942 |
|||
Wintersemester 2017/18 |
|||
Dr. Klaus Wendel |
|||
|
|||
"Go ahead! Was wird kommen, wenn Java wieder eine Insel ist? – Ein Kurs zur Softwareentwicklung mit Go" |
|||
|
|||
Lektion 1: Gaußsche Normalverteilung nach dem Zufallsprinzip |
|||
*/ |
|||
package main |
Binary file not shown.
@ -1,6 +1,11 @@ |
|||
/* |
|||
Landesamt für Geoinformation und Landentwicklung, Referat 35 |
|||
Einführung in die Sprache Go, 25.7.2017 |
|||
Universität Stuttgart, Digital Humanities |
|||
Seminar Nummer 582170942 |
|||
Wintersemester 2017/18 |
|||
Dr. Klaus Wendel |
|||
|
|||
"Go ahead! Was wird kommen, wenn Java wieder eine Insel ist? – Ein Kurs zur Softwareentwicklung mit Go" |
|||
|
|||
Lektion 3: Zeiger |
|||
*/ |
|||
package main |
@ -1,6 +1,11 @@ |
|||
/* |
|||
Landesamt für Geoinformation und Landentwicklung, Referat 35 |
|||
Einführung in die Sprache Go, 25.7.2017 |
|||
Universität Stuttgart, Digital Humanities |
|||
Seminar Nummer 582170942 |
|||
Wintersemester 2017/18 |
|||
Dr. Klaus Wendel |
|||
|
|||
"Go ahead! Was wird kommen, wenn Java wieder eine Insel ist? – Ein Kurs zur Softwareentwicklung mit Go" |
|||
|
|||
Lektion 4: Nebenläufigkeit |
|||
*/ |
|||
package main |
@ -1,6 +1,11 @@ |
|||
/* |
|||
Landesamt für Geoinformation und Landentwicklung, Referat 35 |
|||
Einführung in die Sprache Go, 25.7.2017 |
|||
Universität Stuttgart, Digital Humanities |
|||
Seminar Nummer 582170942 |
|||
Wintersemester 2017/18 |
|||
Dr. Klaus Wendel |
|||
|
|||
"Go ahead! Was wird kommen, wenn Java wieder eine Insel ist? – Ein Kurs zur Softwareentwicklung mit Go" |
|||
|
|||
Lektion 5: Exkurs zu defer, recover, panic => Error Handling; Der Error ist ein Datentyp |
|||
*/ |
|||
|
@ -1,6 +1,11 @@ |
|||
/* |
|||
Landesamt für Geoinformation und Landentwicklung, Referat 35 |
|||
Einführung in die Sprache Go, 25.7.2017 |
|||
Universität Stuttgart, Digital Humanities |
|||
Seminar Nummer 582170942 |
|||
Wintersemester 2017/18 |
|||
Dr. Klaus Wendel |
|||
|
|||
"Go ahead! Was wird kommen, wenn Java wieder eine Insel ist? – Ein Kurs zur Softwareentwicklung mit Go" |
|||
|
|||
Lektion 6: Kommunikation zwischen nebenläufigen Prozessen: "Share memory by communicating, don't communicate by sharing memory." |
|||
*/ |
|||
package main |
@ -1,6 +1,11 @@ |
|||
/* |
|||
Landesamt für Geoinformation und Landentwicklung, Referat 35 |
|||
Einführung in die Sprache Go, 25.7.2017 |
|||
Universität Stuttgart, Digital Humanities |
|||
Seminar Nummer 582170942 |
|||
Wintersemester 2017/18 |
|||
Dr. Klaus Wendel |
|||
|
|||
"Go ahead! Was wird kommen, wenn Java wieder eine Insel ist? – Ein Kurs zur Softwareentwicklung mit Go" |
|||
|
|||
Lektion 7: Löse ein Problem objektorientiert |
|||
*/ |
|||
package main |
@ -1,6 +1,11 @@ |
|||
/* |
|||
Landesamt für Geoinformation und Landentwicklung, Referat 35 |
|||
Einführung in die Sprache Go, 25.7.2017 |
|||
Universität Stuttgart, Digital Humanities |
|||
Seminar Nummer 582170942 |
|||
Wintersemester 2017/18 |
|||
Dr. Klaus Wendel |
|||
|
|||
"Go ahead! Was wird kommen, wenn Java wieder eine Insel ist? – Ein Kurs zur Softwareentwicklung mit Go" |
|||
|
|||
Lektion 8: Exkurs zur Objektorientierung |
|||
*/ |
|||
package main |
Binary file not shown.
@ -1,6 +1,11 @@ |
|||
/* |
|||
Landesamt für Geoinformation und Landentwicklung, Referat 35 |
|||
Einführung in die Sprache Go, 25.7.2017 |
|||
Universität Stuttgart, Digital Humanities |
|||
Seminar Nummer 582170942 |
|||
Wintersemester 2017/18 |
|||
Dr. Klaus Wendel |
|||
|
|||
"Go ahead! Was wird kommen, wenn Java wieder eine Insel ist? – Ein Kurs zur Softwareentwicklung mit Go" |
|||
|
|||
Lektion 10: Unittests, Benchmarks und Profiling |
|||
*/ |
|||
package main |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 322 KiB |
@ -0,0 +1,196 @@ |
|||
/* |
|||
Universität Stuttgart, Digital Humanities |
|||
Seminar Nummer 582170942 |
|||
Wintersemester 2017/18 |
|||
Dr. Klaus Wendel |
|||
|
|||
"Go ahead! Was wird kommen, wenn Java wieder eine Insel ist? – Ein Kurs zur Softwareentwicklung mit Go" |
|||
|
|||
Lektion 11: Apache? Go kann das selber und viel besser! |
|||
*/ |
|||
package main |
|||
|
|||
import ( |
|||
"fmt" |
|||
"log" |
|||
"net/http" |
|||
) |
|||
|
|||
func handler00(w http.ResponseWriter, r *http.Request) { |
|||
fmt.Fprintf(w, "Guckuck %s!", r.URL.Path[1:]) |
|||
fmt.Println(r.URL) |
|||
} |
|||
|
|||
func handler01(w http.ResponseWriter, r *http.Request) { |
|||
fmt.Fprintf(w, `<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="UTF-8"/> |
|||
<title>Testseite 01</title> |
|||
</head> |
|||
<body>Du befindest Dich auf Seite `+"%s"+` (`+"%s"+`-Request)</body> |
|||
</html>`, r.URL.Path[1:], r.Method) |
|||
|
|||
r.ParseForm() |
|||
x := r.Form |
|||
log.Println(x) |
|||
} |
|||
|
|||
func handler02(w http.ResponseWriter, r *http.Request) { |
|||
fmt.Fprintf(w, `<?xml version='1.0' encoding='iso-8859-1'?> |
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd"> |
|||
<html xmlns="http://www.w3.org/1999/xhtml" lang="de" xml:lang="de"> |
|||
<head> |
|||
<meta charset="UTF-8"/> |
|||
<title>Testseite 02</title> |
|||
</head> |
|||
<body>Du befindest Dich auf Seite `+"%s"+` (`+"%s"+`-Request)</body> |
|||
</html>`, r.URL.Path[1:], r.Method) |
|||
|
|||
r.ParseForm() |
|||
x := r.Form |
|||
fmt.Println(x) |
|||
} |
|||
|
|||
func handler03(w http.ResponseWriter, r *http.Request) { |
|||
fmt.Fprintf(w, `<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<title>Basic CRUD Application - jQuery EasyUI CRUD Demo</title> |
|||
<link rel="stylesheet" type="text/css" href="./easyui/themes/default/easyui.css"> |
|||
<link rel="stylesheet" type="text/css" href="./easyui2/themes/icon.css"> |
|||
<link rel="stylesheet" type="text/css" href="http://localhost:8082/easyui/themes/color.css"> |
|||
<link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/demo/demo.css"> |
|||
<script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.min.js"></script> |
|||
<script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.easyui.min.js"></script> |
|||
</head> |
|||
<body> |
|||
<h2>Basic CRUD Application</h2> |
|||
<p>Click the buttons on datagrid toolbar to do crud actions.</p> |
|||
|
|||
<table id="dg" title="My Users" class="easyui-datagrid" style="width:700px;height:250px" |
|||
url = "getSomeJson" |
|||
toolbar="#toolbar" pagination="true" |
|||
rownumbers="true" fitColumns="true" singleSelect="true"> |
|||
<thead> |
|||
<tr> |
|||
<th field="firstname" width="50">First Name</th> |
|||
<th field="lastname" width="50">Last Name</th> |
|||
<th field="phone" width="50">Phone</th> |
|||
<th field="email" width="50">Email</th> |
|||
</tr> |
|||
</thead> |
|||
</table> |
|||
<div id="toolbar"> |
|||
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">New User</a> |
|||
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">Edit User</a> |
|||
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">Remove User</a> |
|||
</div> |
|||
|
|||
<div id="dlg" class="easyui-dialog" style="width:400px" |
|||
closed="true" buttons="#dlg-buttons"> |
|||
<form id="fm" method="post" novalidate style="margin:0;padding:20px 50px"> |
|||
<div style="margin-bottom:20px;font-size:14px;border-bottom:1px solid #ccc">User Information</div> |
|||
<div style="margin-bottom:10px"> |
|||
<input name="firstname" class="easyui-textbox" required="true" label="First Name:" style="width:100%"> |
|||
</div> |
|||
<div style="margin-bottom:10px"> |
|||
<input name="lastname" class="easyui-textbox" required="true" label="Last Name:" style="width:100%"> |
|||
</div> |
|||
<div style="margin-bottom:10px"> |
|||
<input name="phone" class="easyui-textbox" required="true" label="Phone:" style="width:100%"> |
|||
</div> |
|||
<div style="margin-bottom:10px"> |
|||
<input name="email" class="easyui-textbox" required="true" validType="email" label="Email:" style="width:100%"> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
<div id="dlg-buttons"> |
|||
<a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="width:90px">Save</a> |
|||
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a> |
|||
</div> |
|||
<script type="text/javascript"> |
|||
var url; |
|||
function newUser(){ |
|||
$('#dlg').dialog('open').dialog('center').dialog('setTitle','New User'); |
|||
$('#fm').form('clear'); |
|||
url = 'aa'; |
|||
} |
|||
function editUser(){ |
|||
var row = $('#dg').datagrid('getSelected'); |
|||
if (row){ |
|||
$('#dlg').dialog('open').dialog('center').dialog('setTitle','Edit User'); |
|||
$('#fm').form('load',row); |
|||
url = 'bb?id='+row.id; |
|||
} |
|||
} |
|||
function saveUser(){ |
|||
$('#fm').form('submit',{ |
|||
url: url, |
|||
onSubmit: function(){ |
|||
return $(this).form('validate'); |
|||
}, |
|||
success: function(result){ |
|||
var result = eval('('+result+')'); |
|||
if (result.errorMsg){ |
|||
$.messager.show({ |
|||
title: 'Error', |
|||
msg: result.errorMsg |
|||
}); |
|||
} else { |
|||
$('#dlg').dialog('close'); // close the dialog
|
|||
$('#dg').datagrid('reload'); // reload the user data
|
|||
} |
|||
} |
|||
}); |
|||
} |
|||
function destroyUser(){ |
|||
var row = $('#dg').datagrid('getSelected'); |
|||
if (row){ |
|||
$.messager.confirm('Confirm','Are you sure you want to destroy this user?',function(r){ |
|||
if (r){ |
|||
$.post('destroy_user.php',{id:row.id},function(result){ |
|||
if (result.success){ |
|||
$('#dg').datagrid('reload'); // reload the user data
|
|||
} else { |
|||
$.messager.show({ // show error message
|
|||
title: 'Error', |
|||
msg: result.errorMsg |
|||
}); |
|||
} |
|||
},'json'); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
</script> |
|||
</body> |
|||
</html>`) |
|||
} |
|||
|
|||
func handler04(w http.ResponseWriter, r *http.Request) { |
|||
fmt.Fprintf(w, `{"total":"3","rows":[{"id":"1","firstname":"Schnulli","lastname":"Bert","phone":"0711-110","email":"s.bert@schluffi.com"},{"id":"2","firstname":"Schnick","lastname":"Schnack","phone":"00306669666","email":"schnacki@gdotmail.cum"},{"id":"3","firstname":"Susi","lastname":"Schneckenschiß","phone":"036742235141","email":"susi@com.ma"}]}`) |
|||
} |
|||
|
|||
func handler05(w http.ResponseWriter, r *http.Request) { |
|||
fmt.Fprintf(w, "Guckuck %s!", r.URL.Path[1:]) |
|||
fmt.Println(r.URL) |
|||
} |
|||
|
|||
func main() { |
|||
http.HandleFunc("/", handler00) |
|||
http.HandleFunc("/aa", handler01) |
|||
http.HandleFunc("/bb", handler02) |
|||
http.HandleFunc("/cc", handler03) |
|||
http.HandleFunc("/getSomeJson", handler04) |
|||
http.HandleFunc("/easyui/", func(w http.ResponseWriter, r *http.Request) { // wichtig: "/easyui/", nicht "/easyui"
|
|||
http.ServeFile(w, r, r.URL.Path[1:]) |
|||
}) |
|||
// Alternative 2
|
|||
fs := http.FileServer(http.Dir("./easyui/")) |
|||
http.Handle("/easyui2/", http.StripPrefix("/easyui2", fs)) |
|||
// Alternative 3
|
|||
go http.ListenAndServe(":8082", http.FileServer(http.Dir("./"))) // Ein zweiter Server für den Dateizugriff im Hintergrund könnte auch als Dateihandler für jedes File dienen!
|
|||
http.ListenAndServe(":8081", nil) |
|||
} |
@ -1,47 +0,0 @@ |
|||
/* |
|||
Landesamt für Geoinformation und Landentwicklung, Referat 35 |
|||
Einführung in die Sprache Go, 25.7.2017 |
|||
Lektion 11: Ganz einfacher Webserver |
|||
*/ |
|||
package main |
|||
|
|||
import ( |
|||
"fmt" |
|||
"net/http" |
|||
) |
|||
|
|||
func handler00(w http.ResponseWriter, r *http.Request) { |
|||
fmt.Fprintf(w, "Guckuck %s!", r.URL.Path[1:]) |
|||
fmt.Println(r.URL) |
|||
} |
|||
|
|||
func handler01(w http.ResponseWriter, r *http.Request) { |
|||
fmt.Fprintf(w, `<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="UTF-8"/> |
|||
<title>Testseite 01</title> |
|||
</head> |
|||
<body>Du befindest Dich auf Seite `+"%s!"+`</body> |
|||
</html>`, r.URL.Path[1:]) |
|||
} |
|||
|
|||
func handler02(w http.ResponseWriter, r *http.Request) { |
|||
fmt.Fprintf(w, `<?xml version='1.0' encoding='iso-8859-1'?> |
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd"> |
|||
<html xmlns="http://www.w3.org/1999/xhtml" lang="de" xml:lang="de"> |
|||
<head> |
|||
<meta charset="UTF-8"/> |
|||
<title>Testseite 01</title> |
|||
</head> |
|||
<body><b>Du</b> befindest Dich jetzt auf <i>Seite `+"%s!"+`</i></body> |
|||
</html>`, r.URL.Path[1:]) |
|||
} |
|||
|
|||
func main() { |
|||
|
|||
http.HandleFunc("/", handler00) |
|||
http.HandleFunc("/aa", handler01) |
|||
http.HandleFunc("/bb", handler02) |
|||
http.ListenAndServe(":8080", nil) |
|||
} |
Binary file not shown.
@ -1,6 +1,11 @@ |
|||
/* |
|||
Landesamt für Geoinformation und Landentwicklung, Referat 35 |
|||
Einführung in die Sprache Go, 25.7.2017 |
|||
Universität Stuttgart, Digital Humanities |
|||
Seminar Nummer 582170942 |
|||
Wintersemester 2017/18 |
|||
Dr. Klaus Wendel |
|||
|
|||
"Go ahead! Was wird kommen, wenn Java wieder eine Insel ist? – Ein Kurs zur Softwareentwicklung mit Go" |
|||
|
|||
Lektion 12: Ein simpler Listener |
|||
*/ |
|||
package main |
Loading…
Reference in new issue