小编Bap*_*aux的帖子

使用本机Golang API在Windows上添加图标托盘

我正在开发一个没有UI的守护进程,除了Windows系统中的简单图标.

我想对任何其他软件包没有依赖关系,所以我试图使用syscall软件包并自己实现必要的调用.

文档

图书馆

履行

结构

使用xilp/systray文档构建.

type HANDLE uintptr

type HICON HANDLE
    type HWND HANDLE

type GUID struct {
    Data1 uint32
    Data2 uint16
    Data3 uint16
    Data4 [8]byte
}

type NOTIFYICONDATA struct {
    CbSize           uint32
    HWnd             HWND
    UID              uint32
    UFlags           uint32
    UCallbackMessage uint32
    HIcon            HICON
    SzTip            [128]uint16
    DwState          uint32
    DwStateMask      uint32
    SzInfo           [256]uint16 …
Run Code Online (Sandbox Code Playgroud)

windows systray go

13
推荐指数
1
解决办法
2209
查看次数

使用Golang在Windows上启动分离过程

我有一个Golang代码,该代码必须运行一个独立的子进程。

我的实现的Linux版本是syscall.ForkExec这样的。

syscall.ForkExec(my_program, []string{}, nil)
Run Code Online (Sandbox Code Playgroud)

但是我找不到Windows实现。我发现使用的命题START /B

cmd := exec.Command("START", "/B", my_program)
cmd.Start()
Run Code Online (Sandbox Code Playgroud)

不幸的是,START找不到,并且我没有其他使用Golang的解决方案。

windows go

5
推荐指数
1
解决办法
2032
查看次数

base64_encode 和 Convert.base64-encode 之间的 PHP 结果不同

在 PHP 中,存在两种以 Base64 编码内容的方法。我们可以使用base64_encode接受字符串的函数或使用字符串过滤器convert.base64-encode 来与流一起使用。但我无法用这两种方法产生相同的结果。

<?php

$content = "foo";

$encoded1 = base64_encode($content);

$stream = tmpfile();

stream_filter_append($stream, 'convert.base64-encode');

fwrite($stream, $content);
fseek($stream, 0);

$encoded2 = stream_get_contents($stream);

echo sprintf(
    "Content encoded with base64_encode(): %s\nContent encoded with convert.base64-encode filter: %s\n",
    $encoded1,
    $encoded2,
);
Run Code Online (Sandbox Code Playgroud)

输出

Content encoded with base64_encode(): Zm9v
Content encoded with convert.base64-encode filter: Wm05dg==
Run Code Online (Sandbox Code Playgroud)

文档中,可以阅读此引文。

使用这些过滤器相当于分别通过base64_encode()和base64_decode()函数处理所有流数据。

php

5
推荐指数
1
解决办法
1975
查看次数

Doctrine2:类型x已经存在

我有Doctrine API的问题.

我想添加一个新的Doctrine Type.我按照此文档创建了类,并在自定义驱动程序中添加了类型.

Type::addType("custom", "Namespace\NameBundle\Types\CustomType");
$this->registerDoctrineTypeMapping("CustomType", "custom");
Run Code Online (Sandbox Code Playgroud)

当我执行php app/console cache时,我的问题会附加:clear.

[Doctrine\DBAL\DBALException]
Type custom already exists.
Run Code Online (Sandbox Code Playgroud)

经过几次搜索,我发现在Doctrine\DBAL\Types\Type :: addType(...)中如果知道类型就抛出异常...我不明白为什么会抛出这个错误.

api types doctrine

3
推荐指数
1
解决办法
1311
查看次数

foo.Name undefined(类型interface {}没有字段或方法名称)

我使用本机golang包"container/list"来管理堆栈中的inotify事件.当我访问堆栈的项目时,我的类型失败(我认为).

import (
    "golang.org/x/exp/inotify" 
    "container/list"
    "log"
    "fmt"
)

func main() {
    stack := list.New()
    watcher, err := inotify.NewWatcher()

    if err != nil {
        log.Fatal(err)
    }

   err = watcher.Watch(os.Args[1])
   if err != nil {
       log.Fatal(err)
   }

   for {
       select {
           case ev := <-watcher.Event:
               stack.PushFront(ev)

               fmt.Printf("%#v\n", ev)
        }

        foo := stack.Front().Value

        fmt.Printf("%#v\n", foo)
        log.Println("Name: ", foo.Name)
    }
}
Run Code Online (Sandbox Code Playgroud)

当我转储ev变量时,对象类型是&inotify.Event.当我弹出一个项目并转储变量时,我的对象类型是&inotify.Event.

使用错误消息我认为这是接口类型对象接受的问题,但我没有找到如何定义类型.

containers list go

2
推荐指数
1
解决办法
2495
查看次数

标签 统计

go ×3

windows ×2

api ×1

containers ×1

doctrine ×1

list ×1

php ×1

systray ×1

types ×1