Skip to content

Commit e2a8f95

Browse files
authored
Merge pull request #1640 from cogentcore/go25
Update to go v1.25.6 as standard version, and go mod updates
2 parents 50dcded + 70c2daa commit e2a8f95

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+336
-352
lines changed

.github/workflows/core.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: Install Go
3838
uses: actions/setup-go@v5
3939
with:
40-
go-version: '1.23.4'
40+
go-version: '1.25.6'
4141

4242
- name: Install Core
4343
run: go install

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Set up Go
2424
uses: actions/setup-go@v5
2525
with:
26-
go-version: '1.23.4'
26+
go-version: '1.25.6'
2727

2828
- name: Set up Core
2929
run: go install && core setup

base/reflectx/values_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func TestPointerSetRobust(t *testing.T) {
143143
bptr := &b
144144
err := SetRobust(&aptr, bptr)
145145
if err != nil {
146-
t.Errorf(err.Error())
146+
t.Error(err)
147147
}
148148
assert.Equal(t, aptr, bptr)
149149

base/websocket/websocket_generatehtml.go

Lines changed: 0 additions & 31 deletions
This file was deleted.

base/websocket/websocket_notjs.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build !js && !generatehtml
5+
//go:build !js
66

77
package websocket
88

99
import (
1010
"cogentcore.org/core/base/errors"
11+
"cogentcore.org/core/system"
1112
"github.com/gorilla/websocket"
1213
)
1314

@@ -24,6 +25,9 @@ type Client struct {
2425

2526
// Connect connects to a WebSocket server and returns a [Client].
2627
func Connect(url string) (*Client, error) {
28+
if system.GenerateHTMLArg() {
29+
return &Client{}, nil
30+
}
2731
conn, _, err := websocket.DefaultDialer.Dial(url, nil)
2832
if err != nil {
2933
return nil, err
@@ -34,6 +38,9 @@ func Connect(url string) (*Client, error) {
3438
// OnMessage sets a callback function to be called when a message is received.
3539
// This function can only be called once.
3640
func (c *Client) OnMessage(f func(typ MessageTypes, msg []byte)) {
41+
if system.GenerateHTMLArg() {
42+
return
43+
}
3744
go func() {
3845
for {
3946
typ, msg, err := c.conn.ReadMessage()
@@ -48,19 +55,28 @@ func (c *Client) OnMessage(f func(typ MessageTypes, msg []byte)) {
4855

4956
// Send sends a message to the WebSocket server with the given type and message.
5057
func (c *Client) Send(typ MessageTypes, msg []byte) error {
58+
if system.GenerateHTMLArg() {
59+
return nil
60+
}
5161
return c.conn.WriteMessage(int(typ), msg)
5262
}
5363

5464
// Close cleanly closes the WebSocket connection.
5565
// It does not directly trigger [Client.OnClose], but once the connection
5666
// is closed, [Client.OnMessage] will trigger it.
5767
func (c *Client) Close() error {
68+
if system.GenerateHTMLArg() {
69+
return nil
70+
}
5871
return c.conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""))
5972
}
6073

6174
// OnClose sets a callback function to be called when the connection is closed.
6275
// This function can only be called once.
6376
func (c *Client) OnClose(f func()) {
77+
if system.GenerateHTMLArg() {
78+
return
79+
}
6480
go func() {
6581
<-c.done
6682
f()

cli/cli_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ func TestOpen(t *testing.T) {
302302
cfg := &TestConfig{}
303303
err := openWithIncludes(opts, cfg, "testcfg.toml")
304304
if err != nil {
305-
t.Errorf(err.Error())
305+
t.Error(err)
306306
}
307307

308308
// fmt.Println("includes:", cfg.Includes)

cmd/mobile/cert_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
)
1717

1818
func TestSignPKCS7(t *testing.T) {
19+
t.Skip("requires keytool app")
1920
// Setup RSA key.
2021
block, _ := pem.Decode([]byte(testKey))
2122
if block == nil {

cmd/web/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func makeFiles(c *config.Config) error {
109109

110110
preRenderHTML := ""
111111
if c.Web.GenerateHTML {
112-
preRenderHTML, err = exec.Output("go", "run", "-tags", "offscreen,generatehtml", ".")
112+
preRenderHTML, err = exec.Output("go", "run", ".", "-generatehtml", "-nogui")
113113
if err != nil {
114114
return err
115115
}

content/examples/basic/basic.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"cogentcore.org/core/core"
1212
"cogentcore.org/core/htmlcore"
1313
_ "cogentcore.org/core/text/tex"
14+
"cogentcore.org/core/tree"
1415
_ "cogentcore.org/core/yaegicore"
1516
)
1617

@@ -24,7 +25,10 @@ func main() {
2425
ct := content.NewContent(b).SetContent(econtent)
2526
ct.Context.AddWikilinkHandler(htmlcore.GoDocWikilink("doc", "cogentcore.org/core"))
2627
b.AddTopBar(func(bar *core.Frame) {
27-
core.NewToolbar(bar).Maker(ct.MakeToolbar)
28+
core.NewToolbar(bar).Maker(func(p *tree.Plan) {
29+
ct.MakeToolbar(p)
30+
ct.MakeToolbarPDF(p)
31+
})
2832
})
2933
b.RunMainWindow()
3034
}

content/generatehtml.go

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build generatehtml
6-
75
package content
86

97
import (
10-
"fmt"
11-
"os"
128
"strings"
139

1410
"cogentcore.org/core/base/errors"
@@ -18,51 +14,50 @@ import (
1814
"cogentcore.org/core/tree"
1915
)
2016

21-
// This file is activated by the core tool to pre-render Cogent Core apps
22-
// as HTML that can be used as a preview and for SEO purposes.
23-
2417
func init() {
25-
// We override the OnChildAdded set in core/generatehtml.go
26-
core.ExternalParent.AsWidget().SetOnChildAdded(func(n tree.Node) {
27-
var ct *Content
28-
n.AsTree().WalkDown(func(n tree.Node) bool {
29-
if ct != nil {
18+
core.GenerateHTML = generateHTML
19+
}
20+
21+
// GenerateHTML is called by the core tool to pre-render Cogent Core apps
22+
// as HTML that can be used as a preview and for SEO purposes.
23+
func generateHTML(w core.Widget) string {
24+
var ct *Content
25+
w.AsTree().WalkDown(func(n tree.Node) bool {
26+
if ct != nil {
27+
return tree.Break
28+
}
29+
if c, ok := n.(*Content); ok {
30+
ct = c
31+
return tree.Break
32+
}
33+
return tree.Continue
34+
})
35+
if ct == nil {
36+
return core.GenerateHTMLCore(w) // basic fallback
37+
}
38+
prps := []*bcontent.PreRenderPage{}
39+
ct.UpdateTree() // need initial update first
40+
for _, pg := range ct.pages {
41+
ct.Open(pg.URL)
42+
prp := &bcontent.PreRenderPage{
43+
Page: *pg,
44+
HTML: core.GenerateHTMLCore(ct),
45+
}
46+
// The first non-emphasized paragraph is used as the description
47+
// (<em> typically indicates a note or caption, not an introduction).
48+
ct.WalkDown(func(n tree.Node) bool {
49+
if prp.Description != "" {
3050
return tree.Break
3151
}
32-
if c, ok := n.(*Content); ok {
33-
ct = c
34-
return tree.Break
52+
if tx, ok := n.(*core.Text); ok {
53+
if tx.Property("tag") == "p" && !strings.HasPrefix(tx.Text, "<em>") {
54+
prp.Description = tx.Text
55+
return tree.Break
56+
}
3557
}
3658
return tree.Continue
3759
})
38-
if ct == nil {
39-
fmt.Println(core.GenerateHTML(n.(core.Widget))) // basic fallback
40-
os.Exit(0)
41-
}
42-
prps := []*bcontent.PreRenderPage{}
43-
ct.UpdateTree() // need initial update first
44-
for _, pg := range ct.pages {
45-
ct.Open(pg.URL)
46-
prp := &bcontent.PreRenderPage{
47-
Page: *pg,
48-
HTML: core.GenerateHTML(ct),
49-
}
50-
// The first non-emphasized paragraph is used as the description
51-
// (<em> typically indicates a note or caption, not an introduction).
52-
ct.WalkDown(func(n tree.Node) bool {
53-
if prp.Description != "" {
54-
return tree.Break
55-
}
56-
if tx, ok := n.(*core.Text); ok {
57-
if tx.Property("tag") == "p" && !strings.HasPrefix(tx.Text, "<em>") {
58-
prp.Description = tx.Text
59-
return tree.Break
60-
}
61-
}
62-
return tree.Continue
63-
})
64-
prps = append(prps, prp)
65-
}
66-
fmt.Println(string(errors.Log1(jsonx.WriteBytes(prps))))
67-
})
60+
prps = append(prps, prp)
61+
}
62+
return string(errors.Log1(jsonx.WriteBytes(prps)))
6863
}

0 commit comments

Comments
 (0)