Full Mattermost server source with integrated Community Enterprise features. Includes vendor directory for offline/air-gapped builds. Structure: - enterprise-impl/: Enterprise feature implementations - enterprise-community/: Init files that register implementations - enterprise/: Bridge imports (community_imports.go) - vendor/: All dependencies for offline builds Build (online): go build ./cmd/mattermost Build (offline/air-gapped): go build -mod=vendor ./cmd/mattermost 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
52 lines
827 B
Go
52 lines
827 B
Go
//go:build ocr
|
|
|
|
package docconv
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"sync"
|
|
|
|
"github.com/otiai10/gosseract/v2"
|
|
)
|
|
|
|
var config = struct {
|
|
langs []string
|
|
sync.Mutex
|
|
}{
|
|
langs: []string{"eng"},
|
|
}
|
|
|
|
func SetImageLanguages(l ...string) {
|
|
config.Lock()
|
|
config.langs = l
|
|
config.Unlock()
|
|
}
|
|
|
|
// ConvertImage converts images to text.
|
|
// Requires gosseract.
|
|
func ConvertImage(r io.Reader) (string, map[string]string, error) {
|
|
f, err := NewLocalFile(r)
|
|
if err != nil {
|
|
return "", nil, fmt.Errorf("error creating local file: %v", err)
|
|
}
|
|
defer f.Done()
|
|
|
|
meta := make(map[string]string)
|
|
|
|
client := gosseract.NewClient()
|
|
defer client.Close()
|
|
|
|
config.Lock()
|
|
defer config.Unlock()
|
|
|
|
client.SetLanguage(config.langs...)
|
|
client.SetImage(f.Name())
|
|
text, err := client.Text()
|
|
if err != nil {
|
|
return "", nil, err
|
|
}
|
|
|
|
return text, meta, nil
|
|
}
|