在Golang的HTML模板中使用Vue.js [重复]



此问题已经存在 在这里有答案:</ p>





  • 将VueJS与Go后端配合使用



    2个答案
    </ span> \ n </ li>

    </ ul>

    </ div>

    我想将Vue.js与Golang的HTML模板引擎一起使用,但两者都使用 {{ ...}} </ code>的语法,它们彼此冲突... </ p>

    是否有人已经以某种方式做到这一点,或者对如何解决此问题有任何建议? / p>

    谢谢。</ p>
    </ div>

展开原文

原文

This question already has an answer here:

I want to use Vue.js with the Golang's HTML template engine but as both use {{ ... }} for syntax, they conflict with each other...

Does anyone has already did it somehow or have any suggestions on how to overlap this problem?

Thanks in advance.

</div>

2个回答



您可以更改Vue使用的定界符。 查看文档 </ p>
</ div>

展开原文

原文

You can change delimiters used by Vue. Look the documentation

dsgdhf5674
dsgdhf5674 参考:Vue.config.delimiters = ['$ {','}']
接近 4 年之前 回复
dourenzhou8740
dourenzhou8740 谢谢你的帮助! 几秒钟前,我在这里找到了答案stackoverflow.com/a/36530534/3673491(仅供参考)。
接近 4 年之前 回复



您可以更改Go模板的默认分隔符。 使用:</ p>

  func(t 模板)遗留物(左,右字符串) Template 
</ code> </ pre>

文档: https://golang.org/pkg/text/template/#Template.Delims</ a> </ p>
</ div>

展开原文

原文

You can change the default delimiters for Go templates. Use:

func (t *Template) Delims(left, right string) *Template

Docs: https://golang.org/pkg/text/template/#Template.Delims

doupapin172773
doupapin172773 谢谢,这也是有用的信息。 但是我个人更喜欢更改Vue的定界符,而不是Go的定界符。
接近 4 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
我如何在Vue JS中使用Hugo模板

<div class="post-text" itemprop="text"> <p>I created a simple UI in vue.js and I want to call that page on my golang backend, the reason is I want to use both vue.js built in template and hugo template and also for routing.</p> <p>If you use standard html, css, js then you just create a template in golang:</p> <pre><code>t := template.New("") t, _ = t.ParseFiles("/folder/myhtml.html") _ = t.ExecuteTemplate(w, "myhtml.html, myData) </code></pre> <p>How do I create something like this with golang + vue.js and also I currently don't want to use vue router cause I only want one open server and not one for the backend and another one for the front end.</p> </div>

在Golang中使用http.Client.Do进行空HTTP响应

<div class="post-text" itemprop="text"> <p>I am using Go to make an HTTP GET request to an external web service. For some reason, the body of the response is always empty; the content length is always zero bytes. The response status code is always 200, however, and the call to Client.Do returns no error. The request requires an Authorization header, so I am using the http.NewRequest / http.Client.Do pattern to submit the request, as you'll see below. I have done requests similar to these in the past, but never using a GET that required a header. It seems unlikely that this the cause, but I wonder if it may be related. If anyone can spot any potential issues with the pattern used or perhaps has had a similar experience, I'd really appreciate any help.</p> <p>Thank you.</p> <pre><code>if req, err := http.NewRequest("GET", "https://api.molt.in/v1/orders/11111111/items", nil); err != nil { return nil, err } else { client := &amp;http.Client{} req.Header.Add("Authorization", "secretToken") if resp, err := client.Do(req); err != nil { return nil, err } else { defer resp.Body.Close() return readBody(resp.Body) } } </code></pre> </div>

我应该何时在golang中使用panic vs log.fatalln()?

<div class="post-text" itemprop="text"> <p>From the documentation on <a href="https://golang.org/pkg/log/#Fatalln" rel="noreferrer">log.Fatalln()</a>:</p> <blockquote> <p>func Fatalln(v ...interface{}) Fatalln is equivalent to Println() followed by a call to os.Exit(1).</p> </blockquote> <p>The <a href="https://golang.org/src/log/log.go" rel="noreferrer">source code</a> for Fatalln:</p> <pre><code> 310 // Fatalln is equivalent to Println() followed by a call to os.Exit(1). 311 func Fatalln(v ...interface{}) { 312 std.Output(2, fmt.Sprintln(v...)) 313 os.Exit(1) 314 } </code></pre> <p>It seems the main difference is whether or now the error is recoverable (since you can recover a panic) - is there anything more significantly different between these? </p> <p>Panic's interface <a href="https://golang.org/src/builtin/builtin.go?h=func+panic" rel="noreferrer">definition</a> is:</p> <pre><code> 215 // The panic built-in function stops normal execution of the current 216 // goroutine. When a function F calls panic, normal execution of F stops 217 // immediately. Any functions whose execution was deferred by F are run in 218 // the usual way, and then F returns to its caller. To the caller G, the 219 // invocation of F then behaves like a call to panic, terminating G's 220 // execution and running any deferred functions. This continues until all 221 // functions in the executing goroutine have stopped, in reverse order. At 222 // that point, the program is terminated and the error condition is reported, 223 // including the value of the argument to panic. This termination sequence 224 // is called panicking and can be controlled by the built-in function 225 // recover. 226 func panic(v interface{}) </code></pre> <p>It appears panic does not return anything.</p> <p>Is that the primary difference? Otherwise, they seem to perform the same function in an application, assuming the panic is not recovered.</p> </div>

如何在Golang HTML模板中使用算术运算符

<div class="post-text" itemprop="text"> <p>I want to compare field 'FileSize' in my html go temple with variable 'minsize' in my code (.FileSize &lt; *minsize). I have no idea how to do it. See below</p> <pre><code>{{ if lt .FileSize *minsize }} &lt;td style="color:red;"&gt;{{.FileSize}}&lt;/td&gt; {{else}} &lt;td&gt;{{.FileSize}}&lt;/td&gt; {{end}} </code></pre> </div>

Golang HTML模板无法调用HTML文件中的JavaScript文件

<div class="post-text" itemprop="text"> <p>I bundle React app with Webpack after I call it in HTML file. However, it error when I using Golang and html/template to view HTML file.<br><br> My HTML file: index.html<br><br></p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;Note App&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="root"&gt;&lt;/div&gt; &lt;script src="public/bundle.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><br><br> My Golang file: index.go<br><br></p> <pre><code>package main import ( "net/http" "html/template" "path/filepath" ) func handle(w http.ResponseWriter, r *http.Request) { fp := filepath.Join("views", "index.html") t := template.Must(template.ParseFiles(fp)) t.Execute(w, nil) } func main() { http.HandleFunc("/", handle) http.ListenAndServe(":8080", nil) } </code></pre> </div>

在Golang中,为什么conn.Write tcp响应为空?

<div class="post-text" itemprop="text"> <p>I have a tcp server that reads a file that sends the file content to the client.</p> <p>The 'status.txt' file contains only a boolean.</p> <p>When I curl, this shows <code>true</code> (with leading space).</p> <pre><code>dat, err := ioutil.ReadFile("./status.txt") conn.Write([]byte(" " + string(dat))) </code></pre> <p>Whereas this code results in <code>curl: (52) Empty reply from server</code>. </p> <pre><code>conn.Write([]byte(string(dat))) </code></pre> <p>Any clue why this happens? I don't want to have to pad my response string.</p> </div>

在Golang中提取* html.Node的位置偏移

<div class="post-text" itemprop="text"> <p>How do I can extract positional offset for specific node of already parsed HTML document? For example, for document <code>&lt;div&gt;Hello, &lt;b&gt;World!&lt;/b&gt;&lt;/div&gt;</code> I want to be able to know that offset of <code>World!</code> is <code>15:21</code>. Document may be changed while parsing.</p> <p>I have a solution to render whole document with special marks, but it's really bad for performance. Any ideas?</p> <pre><code>package main import ( "bytes" "golang.org/x/net/html" "golang.org/x/net/html/atom" "log" "strings" ) func nodeIndexOffset(context *html.Node, node *html.Node) (int, int) { if node.Type != html.TextNode { node = node.FirstChild } originalData := node.Data var buf bytes.Buffer node.Data = "|start|" + originalData _ = html.Render(&amp;buf, context.FirstChild) start := strings.Index(buf.String(), "|start|") buf = bytes.Buffer{} node.Data = originalData + "|end|" _ = html.Render(&amp;buf, context.FirstChild) end := strings.Index(buf.String(), "|end|") node.Data = originalData return start, end } func main() { s := "&lt;div&gt;Hello, &lt;b&gt;World!&lt;/b&gt;&lt;/div&gt;" var context html.Node context = html.Node{ Type: html.ElementNode, Data: "body", DataAtom: atom.Body, } nodes, err := html.ParseFragment(strings.NewReader(s), &amp;context) if err != nil { log.Fatal(err) } for _, node := range nodes { context.AppendChild(node) } world := nodes[0].FirstChild.NextSibling.FirstChild log.Println("target", world) log.Println(nodeIndexOffset(&amp;context, world)) } </code></pre> </div>

使用Golang json.NewDecoder / json.NewEncoder

<div class="post-text" itemprop="text"> <p>I'm a total noob at go and I'm trying to understand what I'm missing here. I'm expecting to use <code>dec.Decode</code> to loop over the json values and end up with a map of the response. What I'm getting is the entire json string as the key to the first element of the map. What am I missing?</p> <p>Example response:</p> <p><code>2015/03/02 10:03:16 map[error:invalid_request error_description:that is not a recognized WePay API call error_code:1001] map[string]interface {}</code></p> <pre><code>package main import ( "encoding/json" "io" "log" "net/http" "reflect" ) func main() { var v map[string]interface{} resp, err := http.Get("https://wepayapi.com/v2/") if err != nil { log.Println("Error: " + err.Error()) } defer resp.Body.Close() // resp.Body is an io.ReadCloser... NewDecoder expects an io.Reader dec := json.NewDecoder(resp.Body) // Decode reads the next JSON-encoded value from its input and stores it in the value pointed to by v. for err := dec.Decode(&amp;v); err != nil &amp;&amp; err != io.EOF; { log.Println("ERROR: " + err.Error()) return } log.Println(v, reflect.TypeOf(v)) } </code></pre> </div>

在golang中使用http.Client.Get方法和Body.Read()方法处理时,EOF错误导致终止

<div class="post-text" itemprop="text"> <p>I am using an http client to get a json body, and read it to a byte array like</p> <pre><code>client := new(http.Client) client.Timeout = time.Second * 10 GetJobJson, err := client.Get(joblocation.String()) //where joblocation is of type *url.Url if err != nil { errorlog.Err.Println("Error getting job from", joblocation.String(), err) return false, http.StatusBadRequest, nil } buff := make([]byte, GetJobJson.ContentLength) length, err := GetJobJson.Body.Read(buff) //This returns an EOF error if err != nil { errorlog.Err.Println("Error reading request body of length", length, "vs contentlength", GetJobJson.ContentLength, err) return false, http.StatusBadRequest, nil } </code></pre> <p>In the above code, <code>GetJobJson.Body</code> is of type <code>io.ReadCloser</code>, which implements <code>Reader</code>, having <code>Read</code> method, which I am using here as </p> <pre><code>length, err := GetJobJson.Body.Read(buff) </code></pre> <p>But since I am handling error here, it is returning an error which says EOF. </p> <p>The http endpoint to where I am sending the request is running an apache server, mentioning it here since I am not sure if it matters.</p> <p>If I am not handling the error, I get the complete json body, which is there in the remote server, and the program continues to work as expected. </p> <p>What is the best way to handle this? Is the <code>Read</code> method that I use, is bad for this situation? Please advise.</p> <p>Thank you.</p> </div>

如何在golang中的mongo中将bson.M元素列表组合成单个bson.M?

<div class="post-text" itemprop="text"> <pre><code>lstMap := make([]interface{}, 0) lstMap = mongoOps.AddToBsonMap(lstMap, bson.M{"$inc": bson.M{"Google.ab.Value": 1}}) lstMap = mongoOps.AddToBsonMap(lstMap, bson.M{"$inc": bson.M{"Google.ab1.Value1": 1}}) func (o *MongoOps) AddToBsonMap(lstMap []interface{}, value interface{}) (result []interface{}) { lstMap = append(lstMap, value) return lstMap </code></pre> <p>}</p> <pre><code> I want the in this format : bson.M{"$inc": bson.M{"Google.ab.Value": 1, "AB.Value.to": 2}} </code></pre> <p>All the operation of same key needs to be appended.Thank you in advance</p> </div>

在golang中获取未定义的rand.Shuffle

<div class="post-text" itemprop="text"> <p>So I have a slice of letters and want to shuffle them. I've implemented this code snippet:</p> <pre><code>rand.Shuffle(len(letters), func(i, j int) { letters[i], letters[j] = letters[j], letters[i] )} </code></pre> <p>When running the program it gets stuck at the first line saying: "undefined: rand.Shuffle". in my import declaration i have imported "math/rand" I also run this code snippet before the snippet with a problem:</p> <pre><code>rand.Seed(seed) </code></pre> <p>Where "seed" is given earlier in the code.</p> <p>Also what i want is to shuffle a word but don't touch the first and last letter. Is there an easy solution to this. I have written the code like this:</p> <pre><code>rand.Shuffle(len(letters), func(i, j int) { if i &gt; 0 &amp;&amp; i &lt; (len(letters) - 1) &amp;&amp; j &gt; 0 &amp;&amp; j &lt; (len(letters) - 1){ letters[i], letters[j] = letters[j], letters[i] } }) </code></pre> <p>Full code:</p> <pre><code>import ( "math/rand" "strings" "regexp" ) func splitText(text string) []string { re := regexp.MustCompile("[A-Za-z0-9']+|[':;?().,!\\ ]") return re.FindAllString(text, -1) } func scramble(text string, seed int64) string { token := splitText(text) rand.Seed(seed) if len(token) != 0{ for i := 0; i &lt; len(token); i++{ word := token[i] if len(word) &gt; 3{ letters := strings.Split(word, "") rand.Shuffle(len(letters), func(i, j int) { if i &gt; 0 &amp;&amp; i &lt; (len(letters) - 1) &amp;&amp; j &gt; 0 &amp;&amp; j &lt; (len(letters) - 1){ letters[i], letters[j] = letters[j], letters[i] } }) token[i] = strings.Join(letters, "") } } } returnString := strings.Join(token, "") return returnString </code></pre> <p>}</p> </div>

Golang可以安全地切换cmd.Stdout

<div class="post-text" itemprop="text"> <p>I execute process with Go and write output to file (log file)</p> <pre><code> cmd := exec.Command(path) cmd.Dir = dir t := time.Now() t1 := t.Format("20060102-150405") fs, err := os.Create(dir + "/var/log/" + t1 + ".std") if err == nil { cmd.Stdout = fs } </code></pre> <p>I wish to rotate logs and change log file daily <a href="http://golang.org/pkg/os/exec/">http://golang.org/pkg/os/exec/</a></p> <pre><code> // Stdout and Stderr specify the process's standard output and error. // // If either is nil, Run connects the corresponding file descriptor // to the null device (os.DevNull). // // If Stdout and Stderr are the same writer, at most one // goroutine at a time will call Write. Stdout io.Writer Stderr io.Writer </code></pre> <p>Is it safe to change cmd.Stdout variable daily from arbitary goroutine or I have to implement goroutine that will copy from Stdout to another file and switch files?</p> </div>

如何集成Golang后端和Javascript(three.js)前端?

<div class="post-text" itemprop="text"> <p>I would like to write a 3D application using Golang, my favorite programming language. However, I would prefer not to use native OpenGL directly as the graphical frontend as this would entail a larger learning curve than I'm willing to tolerate. Additionally, I don't really want to use a Golang game engine like go:ngine. </p> <p>After doing some research I found out about the amazing WebGL Javascript library three.js and I was so intrigued that I completed an introductory Javascript course in a few hours. I'm not really a web developer at all, so I'm wondering how practical it would be for me to write my application primarily in Go but with a three.js frontend.</p> <p>Some specific questions:</p> <ul> <li>Is it worthwhile / practical to use Javascript/three.js as a frontend to a Golang server like this?</li> <li>If it is worthwhile, where can I look to learn how to integrate the two cleanly?</li> <li>If it isn't really worthwhile, which alternatives do I have?</li> </ul> <p>Thanks, any response appreciated.</p> <h2>Edit:</h2> <blockquote> <p>Do you plan to make operations on geometry in Go, possibly in realtime and communicate with your Javascript layer using Websockets?</p> </blockquote> <p>Yes, this is what I'm thinking now. I'm intending my (Golang) program to generate streams of vertices and triangles based on a few parameters from the user. Each "structure" is generated all at once after the users supply their parameters (which I see as slider bars + input boxes on a Javascript frontend).</p> <p>Here's an example of something the Go program might generate, plotted in GNUPlot: <a href="https://i.stack.imgur.com/1rbbx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1rbbx.png" alt="pic"></a><br> <sub>(source: <a href="http://drive.alexozer.com/helix-fractal.png" rel="nofollow noreferrer">alexozer.com</a>)</sub> </p> <blockquote> <p>If this is the case you underestimate Javascript a bit. You should write most of your application in Javascript and use Go as a classical backend service layer like user accounts, persisting state, etc.</p> </blockquote> <p>I'd be fine with doing that, except for these reasons:</p> <ul><li>The core generating process fundamentally depends on Goroutines and channels</li> <li>I know close to nothing about web development, including frontend and backend</li></ul> <p>So I suppose I'm asking about the implementation details of one of these three possibilities: </p><li>Writing most of the program, including the generator, in JS, and a minimal backend in Go</li> <li>Writing most of the program in Go and using JS just as a graphical frontend</li> <li>Something else?</li> </div>

tour.golang.org#36 pic.Show实现的功能

<div class="post-text" itemprop="text"> <p>In <a href="http://tour.golang.org/moretypes/14" rel="nofollow noreferrer">tour.golang.org , exercice 36 </a>, what this statement <code>pic.Show(Pic)</code> supposed to do?</p> <pre><code>package main import "code.google.com/p/go-tour/pic" func Pic(dx, dy int) [][]uint8 { var p = make([]([]uint8), dy) for i := 0; i &lt; len(p); i++ { p[i] = make([]uint8, dx) for j := 0; j &lt; len(p[i]); j++ { p[i][j] = uint8((i + j) / 2) } } return p } func main() { pic.Show(Pic) } </code></pre> <p>when I run the example, it just print some characters on the standard output, isn’t supposed to show some picture?</p> </div>

如何在golang中关闭bufio.Reader / Writer?

<div class="post-text" itemprop="text"> <p>How can I close <code>bufio.Reader</code> or <code>bufio.Writer</code> in golang?</p> <pre><code>func init(){ file,_ := os.Create("result.txt") writer = bufio.NewWriter(file) } </code></pre> <p>Should I close <code>Writer</code>? or just use <code>file.Close()</code> will make <code>Writer</code> close?</p> </div>

如何在Golang中检查指向结构net.IPNet的Pointer的nil值

<div class="post-text" itemprop="text"> <p>How can I check the nil value as a result of the assignment of variable b below?</p> <pre><code>package main import ( "fmt" "net" ) type Subnet struct { ID int IP *net.IPNet } func main() { var s = Subnet{ ID: 12345, IP: &amp;net.IPNet{ IP: net.IP{10, 1, 232, 0}, Mask: net.IPMask{255, 255, 255, 0}, }, } fmt.Printf("%+v ", s) var b = Subnet{ ID: 12345, IP: &amp;net.IPNet{}, } fmt.Printf("%+v ", b) if b.IP == nil { fmt.Println("hello there") } } </code></pre> <p>Here is the go playground <a href="https://play.golang.org/p/Jk6_3ofyH5" rel="nofollow noreferrer">https://play.golang.org/p/Jk6_3ofyH5</a></p> <p>Basically, I expect that "hello there" will be printed out as b.IP is nil, but it did not.</p> </div>

Golang中的HTML模板

<div class="post-text" itemprop="text"> <p>I'm following this tutorial: <a href="https://golang.org/doc/articles/wiki/" rel="nofollow">golang tutorial - wiki</a> and I've managed to get everything working except the last point in the "other task" section. My Implementation of the tutorial:</p> <pre><code>package main import ( "fmt" "io/ioutil" "net/http" "html/template" "regexp" ) type Page struct { Title string Body []byte } func (p *Page) save() error { filename := "data/" + p.Title + ".txt" return ioutil.WriteFile(filename, p.Body, 0600) } func loadPage(title string) (*Page, error) { filename := "data/" + title + ".txt" body, err := ioutil.ReadFile(filename) if err != nil { return nil, err } return &amp;Page{Title: title, Body: body}, nil } func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) { t, _ := template.ParseFiles("template/" + tmpl + ".html"); t.Execute(w, p) } func viewHandler(w http.ResponseWriter, r *http.Request) { title := r.URL.Path[len("/view/"):] p, err := loadPage(title) if err != nil { http.Redirect(w, r, "/edit/" + title, http.StatusFound); return } expr := regexp.MustCompile(`\[.+\]`) p.Body = expr.ReplaceAllFunc(p.Body, func ( match []byte) []byte { return []byte("&lt;a href='/view/" + string(match) + "'&gt;" + string(match) + "&lt;/a&gt;") }) renderTemplate(w, "view", p); } func saveHandler(w http.ResponseWriter, r *http.Request) { title := r.URL.Path[len("/save/"):] body := r.FormValue("body") p := &amp;Page{Title: title, Body: []byte(body)} p.save() http.Redirect(w, r, "/view/" + title, http.StatusFound) } func editHandler(w http.ResponseWriter, r *http.Request) { title := r.URL.Path[len("/edit/"):] p, err := loadPage(title); if err != nil { p = &amp;Page{Title: title} } renderTemplate(w, "edit", p); } func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/view/index", http.StatusFound) }) http.HandleFunc("/view/", viewHandler) http.HandleFunc("/edit/", editHandler) http.HandleFunc("/save/", saveHandler) http.ListenAndServe(":8080", nil) fmt.Println("Running"); } </code></pre> <p>html/template engine prints the anchor tag as expected, but escapes it with html entities. I've not been able to find appropriate way of doing it.</p> </div>

如何在Golang中倒带io.ReadCloser?

<div class="post-text" itemprop="text"> <p>I'm perpetually caught out by reading an <strong>io.ReadCloser</strong> and then forgetting that I've read it before, and when I read it again, I get an empty payload. I wish there was some lint check for my stupidity. Nonetheless, I think I can use TeeReader, but it fails to meet my expectations here:</p> <pre><code>func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { buf := &amp;bytes.Buffer{} tee := io.TeeReader(r.Body, buf) body, err := ioutil.ReadAll(tee) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } log.Println("body", string(body)) payload, err := httputil.DumpRequest(r, true) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } log.Println("dump request", string(payload)) w.WriteHeader(http.StatusOK) }) log.Fatal(http.ListenAndServe(":8080", nil)) } </code></pre> <p>The body is missing from my "dump request" log line.</p> <p>I.e. when I run <code>curl -i -X POST --data '{"username":"xyz","password":"xyz"}' http://localhost:8080</code></p> <p>I want the original request in full:</p> <pre><code>2019/01/14 11:09:50 dump request POST / HTTP/1.1 Host: localhost:8080 Accept: */* Content-Length: 35 Content-Type: application/x-www-form-urlencoded User-Agent: curl/7.63.0 {"username":"xyz","password":"xyz"} </code></pre> <p>What am I missing?</p> </div>

Golang:带有tls.dial的https请求

<div class="post-text" itemprop="text"> <p>i am trying to make https request with golang. </p> <pre><code>conf := &amp;tls.Config{ InsecureSkipVerify: true, MinVersion:tls.VersionTLS10, } //TLS connection tlsCon, err := tls.Dial("tcp", "youtube.com:443", conf) if err != nil { fmt.Println("SSL Error : " + err.Error()) return } defer tlsCon.Close() state := tlsCon.ConnectionState() fmt.Println("SSL ServerName : " + state.ServerName) fmt.Println("SSL Handshake : ", state.HandshakeComplete) fmt.Println("SSL Mutual : ", state.NegotiatedProtocolIsMutual) request = ' CONNECT youtube.com:443 HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0 Proxy-Connection: close Connection: close Host: youtube.com:443 ' n, err = io.WriteString(tlsCon, request) if err != nil { fmt.Println("SSL Write error :", err.Error(), n) } n, err = tlsCon.Read(data) if err != nil { fmt.Println("SSL Read error : " + err.Error()) return } </code></pre> <p>this is my code , state.HandshakeComplete, state.NegotiatedProtocolIsMutual returns true and state.ServerName returns = ''</p> <p>when i write data to tls connection no error returns also tls connection never reply my request.</p> <p>any help appricated. thanks.</p> </div>

软件测试入门、SQL、性能测试、测试管理工具

软件测试2小时入门,让您快速了解软件测试基本知识,有系统的了解; SQL一小时,让您快速理解和掌握SQL基本语法 jmeter性能测试 ,让您快速了解主流来源性能测试工具jmeter 测试管理工具-禅道,让您快速学会禅道的使用,学会测试项目、用例、缺陷的管理、

计算机组成原理实验教程

西北工业大学计算机组成原理实验课唐都仪器实验帮助,同实验指导书。分为运算器,存储器,控制器,模型计算机,输入输出系统5个章节

Java 最常见的 200+ 面试题:面试必备

这份面试清单是从我 2015 年做了 TeamLeader 之后开始收集的,一方面是给公司招聘用,另一方面是想用它来挖掘在 Java 技术栈中,还有那些知识点是我不知道的,我想找到这些技术盲点,然后修复它,以此来提高自己的技术水平。虽然我是从 2009 年就开始参加编程工作了,但我依旧觉得自己现在要学的东西很多,并且学习这些知识,让我很有成就感和满足感,那所以何乐而不为呢? 说回面试的事,这份面试...

winfrom中嵌套html,跟html的交互

winfrom中嵌套html,跟html的交互,源码就在里面一看就懂,很简单

玩转Python-Python3基础入门

总课时80+,提供源码和相关资料 本课程从Python零基础到纯Python项目实战。内容详细,案例丰富,覆盖了Python知识的方方面面,学完后不仅对Python知识有个系统化的了解,让你从Python小白变编程大牛! 课程包含: 1.python安装 2.变量、数据类型和运算符 3.选择结构 4.循环结构 5.函数和模块 6.文件读写 7.了解面向对象 8.异常处理

程序员的兼职技能课

获取讲师答疑方式: 在付费视频第一节(触摸命令_ALL)片头有二维码及加群流程介绍 限时福利 原价99元,今日仅需39元!购课添加小助手(微信号:csdn590)按提示还可领取价值800元的编程大礼包! 讲师介绍: 苏奕嘉&nbsp;前阿里UC项目工程师 脚本开发平台官方认证满级(六级)开发者。 我将如何教会你通过【定制脚本】赚到你人生的第一桶金? 零基础程序定制脚本开发课程,是完全针对零脚本开发经验的小白而设计,课程内容共分为3大阶段: ①前期将带你掌握Q开发语言和界面交互开发能力; ②中期通过实战来制作有具体需求的定制脚本; ③后期将解锁脚本的更高阶玩法,打通任督二脉; ④应用定制脚本合法赚取额外收入的完整经验分享,带你通过程序定制脚本开发这项副业,赚取到你的第一桶金!

HoloLens2开发入门教程

本课程为HoloLens2开发入门教程,讲解部署开发环境,安装VS2019,Unity版本,Windows SDK,创建Unity项目,讲解如何使用MRTK,编辑器模拟手势交互,打包VS工程并编译部署应用到HoloLens上等。

基于VHDL的16位ALU简易设计

基于VHDL的16位ALU简易设计,可完成基本的加减、带进位加减、或、与等运算。

MFC一站式终极全套课程包

该套餐共包含从C小白到C++到MFC的全部课程,整套学下来绝对成为一名C++大牛!!!

利用Verilog实现数字秒表(基本逻辑设计分频器练习)

设置复位开关。当按下复位开关时,秒表清零并做好计时准备。在任何情况下只要按下复位开关,秒表都要无条件地进行复位操作,即使是在计时过程中也要无条件地进行清零操作。 设置启/停开关。当按下启/停开关后,将

董付国老师Python全栈学习优惠套餐

购买套餐的朋友可以关注微信公众号“Python小屋”,上传付款截图,然后领取董老师任意图书1本。

Python可以这样学(第一季:Python内功修炼)

董付国系列教材《Python程序设计基础》、《Python程序设计(第2版)》、《Python可以这样学》配套视频,讲解Python 3.5.x和3.6.x语法、内置对象用法、选择与循环以及函数设计与使用、lambda表达式用法、字符串与正则表达式应用、面向对象编程、文本文件与二进制文件操作、目录操作与系统运维、异常处理结构。

计算机操作系统 第三版.pdf

计算机操作系统 第三版 本书全面介绍了计算机系统中的一个重要软件——操作系统(OS),本书是第三版,对2001年出版的修订版的各章内容均作了较多的修改,基本上能反映当前操作系统发展的现状,但章节名称基

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

Vue.js 2.0之全家桶系列视频课程

基于新的Vue.js 2.3版本, 目前新全的Vue.js教学视频,让你少走弯路,直达技术前沿! 1. 包含Vue.js全家桶(vue.js、vue-router、axios、vuex、vue-cli、webpack、ElementUI等) 2. 采用笔记+代码案例的形式讲解,通俗易懂

微信公众平台开发入门

本套课程的设计完全是为初学者量身打造,课程内容由浅入深,课程讲解通俗易懂,代码实现简洁清晰。通过本课程的学习,学员能够入门微信公众平台开发,能够胜任企业级的订阅号、服务号、企业号的应用开发工作。 通过本课程的学习,学员能够对微信公众平台有一个清晰的、系统性的认识。例如,公众号是什么,它有什么特点,它能做什么,怎么开发公众号。 其次,通过本课程的学习,学员能够掌握微信公众平台开发的方法、技术和应用实现。例如,开发者文档怎么看,开发环境怎么搭建,基本的消息交互如何实现,常用的方法技巧有哪些,真实应用怎么开发。

150讲轻松搞定Python网络爬虫

【为什么学爬虫?】 &nbsp; &nbsp; &nbsp; &nbsp;1、爬虫入手容易,但是深入较难,如何写出高效率的爬虫,如何写出灵活性高可扩展的爬虫都是一项技术活。另外在爬虫过程中,经常容易遇到被反爬虫,比如字体反爬、IP识别、验证码等,如何层层攻克难点拿到想要的数据,这门课程,你都能学到! &nbsp; &nbsp; &nbsp; &nbsp;2、如果是作为一个其他行业的开发者,比如app开发,web开发,学习爬虫能让你加强对技术的认知,能够开发出更加安全的软件和网站 【课程设计】 一个完整的爬虫程序,无论大小,总体来说可以分成三个步骤,分别是: 网络请求:模拟浏览器的行为从网上抓取数据。 数据解析:将请求下来的数据进行过滤,提取我们想要的数据。 数据存储:将提取到的数据存储到硬盘或者内存中。比如用mysql数据库或者redis等。 那么本课程也是按照这几个步骤循序渐进的进行讲解,带领学生完整的掌握每个步骤的技术。另外,因为爬虫的多样性,在爬取的过程中可能会发生被反爬、效率低下等。因此我们又增加了两个章节用来提高爬虫程序的灵活性,分别是: 爬虫进阶:包括IP代理,多线程爬虫,图形验证码识别、JS加密解密、动态网页爬虫、字体反爬识别等。 Scrapy和分布式爬虫:Scrapy框架、Scrapy-redis组件、分布式爬虫等。 通过爬虫进阶的知识点我们能应付大量的反爬网站,而Scrapy框架作为一个专业的爬虫框架,使用他可以快速提高我们编写爬虫程序的效率和速度。另外如果一台机器不能满足你的需求,我们可以用分布式爬虫让多台机器帮助你快速爬取数据。 &nbsp; 从基础爬虫到商业化应用爬虫,本套课程满足您的所有需求! 【课程服务】 专属付费社群+每周三讨论会+1v1答疑

SEIR课程设计源码与相关城市数据.rar

SEIR结合学报与之前博客结合所做的一些改进,选择其中三个城市进行拟合仿真SEIR结合学报与之前博客结合所做的一些改进,选择其中三个城市进行拟合仿真SEIR结合学报与之前博客结合所做的一些改进,选择其

Python数据挖掘简易入门

&nbsp; &nbsp; &nbsp; &nbsp; 本课程为Python数据挖掘方向的入门课程,课程主要以真实数据为基础,详细介绍数据挖掘入门的流程和使用Python实现pandas与numpy在数据挖掘方向的运用,并深入学习如何运用scikit-learn调用常用的数据挖掘算法解决数据挖掘问题,为进一步深入学习数据挖掘打下扎实的基础。

2019 AI开发者大会

2019 AI开发者大会(AI ProCon 2019)是由中国IT社区CSDN主办的AI技术与产业年度盛会。多年经验淬炼,如今蓄势待发:2019年9月6-7日,大会将有近百位中美顶尖AI专家、知名企业代表以及千余名AI开发者齐聚北京,进行技术解读和产业论证。我们不空谈口号,只谈技术,诚挚邀请AI业内人士一起共铸人工智能新篇章!

Java面试题大全(2020版)

发现网上很多Java面试题都没有答案,所以花了很长时间搜集整理出来了这套Java面试题大全,希望对大家有帮助哈~ 本套Java面试题大全,全的不能再全,哈哈~ 一、Java 基础 1. JDK 和 JRE 有什么区别? JDK:Java Development Kit 的简称,java 开发工具包,提供了 java 的开发环境和运行环境。 JRE:Java Runtime Environ...

定量遥感中文版 梁顺林著 范闻捷译

这是梁顺林的定量遥感的中文版,由范闻捷等翻译的,是电子版PDF,解决了大家看英文费时费事的问题,希望大家下载看看,一定会有帮助的

GIS程序设计教程 基于ArcGIS Engine的C#开发实例

张丰,杜震洪,刘仁义编著.GIS程序设计教程 基于ArcGIS Engine的C#开发实例.浙江大学出版社,2012.05

人工智能-计算机视觉实战之路(必备算法+深度学习+项目实战)

系列课程主要分为3大阶段:(1)首先掌握计算机视觉必备算法原理,结合Opencv进行学习与练手,通过实际视项目进行案例应用展示。(2)进军当下最火的深度学习进行视觉任务实战,掌握深度学习中必备算法原理与网络模型架构。(3)结合经典深度学习框架与实战项目进行实战,基于真实数据集展开业务分析与建模实战。整体风格通俗易懂,项目驱动学习与就业面试。 建议同学们按照下列顺序来进行学习:1.Python入门视频课程 2.Opencv计算机视觉实战(Python版) 3.深度学习框架-PyTorch实战/人工智能框架实战精讲:Keras项目 4.Python-深度学习-物体检测实战 5.后续实战课程按照自己喜好选择就可以

三个项目玩转深度学习(附1G源码)

从事大数据与人工智能开发与实践约十年,钱老师亲自见证了大数据行业的发展与人工智能的从冷到热。事实证明,计算机技术的发展,算力突破,海量数据,机器人技术等,开启了第四次工业革命的序章。深度学习图像分类一直是人工智能的经典任务,是智慧零售、安防、无人驾驶等机器视觉应用领域的核心技术之一,掌握图像分类技术是机器视觉学习的重中之重。针对现有线上学习的特点与实际需求,我们开发了人工智能案例实战系列课程。打造:以项目案例实践为驱动的课程学习方式,覆盖了智能零售,智慧交通等常见领域,通过基础学习、项目案例实践、社群答疑,三维立体的方式,打造最好的学习效果。

微信小程序开发实战之番茄时钟开发

微信小程序番茄时钟视频教程,本课程将带着各位学员开发一个小程序初级实战类项目,针对只看过官方文档而又无从下手的开发者来说,可以作为一个较好的练手项目,对于有小程序开发经验的开发者而言,可以更好加深对小程序各类组件和API 的理解,为更深层次高难度的项目做铺垫。

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

去除异常值matlab程序

数据预处理中去除异常值的程序,matlab写成

用verilog HDL语言编写的秒表

在秒表设计中,分模块书写。用在七段数码管上显示。输入频率是1KHZ.可以显示百分秒,秒,分。如要显示小时,只需修改leds里的代码和主模块代码。改程序以通过硬件电路验证。完全正确。

[透视java——反编译、修补和逆向工程技术]源代码

源代码。

相关热词 c#框体中的退出函数 c# 按钮透明背景 c# idl 混编出错 c#在位置0处没有任何行 c# 循环给数组插入数据 c# 多线程死锁的例子 c# 钉钉读取员工排班 c# label 不显示 c#裁剪影像 c#工作进程更新ui
立即提问